all tasks
This commit is contained in:
parent
b83f433714
commit
68f8f3e56b
14735 changed files with 178959 additions and 0 deletions
19
Task/String-concatenation/Objective-C/string-concatenation.m
Normal file
19
Task/String-concatenation/Objective-C/string-concatenation.m
Normal file
|
|
@ -0,0 +1,19 @@
|
|||
#import <Foundation/Foundation.h>
|
||||
|
||||
int main()
|
||||
{
|
||||
NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
|
||||
NSString *s = @"hello";
|
||||
printf("%s%s\n", [s UTF8String], " literal");
|
||||
|
||||
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]);
|
||||
|
||||
[pool release];
|
||||
return 0;
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue