RosettaCodeData/Task/String-concatenation/Objective-C/string-concatenation.m

21 lines
475 B
Mathematica
Raw Permalink Normal View History

2013-04-11 01:07:29 -07:00
#import <Foundation/Foundation.h>
int main()
{
2014-04-02 16:56:35 +00:00
@autoreleasepool {
2013-04-11 01:07:29 -07:00
2014-04-02 16:56:35 +00:00
NSString *s = @"hello";
printf("%s%s\n", [s UTF8String], " literal");
2013-04-11 01:07:29 -07:00
2014-04-02 16:56:35 +00:00
NSString *s2 = [s stringByAppendingString:@" literal"];
// or, NSString *s2 = [NSString stringWithFormat:@"%@%@", s, @" literal"];
puts([s2 UTF8String]);
/* or */
NSMutableString *s3 = [NSMutableString stringWithString: s];
[s3 appendString: @" literal"];
puts([s3 UTF8String]);
}
2013-04-11 01:07:29 -07:00
return 0;
}