Created
March 25, 2013 07:29
-
-
Save tediscript/5235459 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| NSString *string1 = @"This is"; | |
| NSString *string2 = @" a test."; | |
| NSString *string3 = [string1 stringByAppendingString:string2]; | |
| // string3 is now @"This is a test." string1 and string2 are unchanged. | |
| //You can also assign the new string back to string1: | |
| NSString *string1 = @"This is"; | |
| NSString *string2 = @" a test."; | |
| string1 = [string1 stringByAppendingString:string2]; | |
| // string1 is now @"This is a test." | |
| //If you're using a NSMutableString, you can simply call the appendString method: | |
| NSMutableString *string1 = [NSMutableString stringWithString:@"This is"]; | |
| NSString *string2 = @" a test."; | |
| [string1 appendString:string2]; | |
| NSLog(@"string1: %@", string1); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment