Created
March 14, 2014 15:02
-
-
Save shto/9549405 to your computer and use it in GitHub Desktop.
Example of passing by reference in Objective-C
This file contains 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
static void ChangeString(NSMutableString *theString) { | |
[theString insertString:@"xyzabc" atIndex:3]; | |
NSLog(@"String inside ChangeString: %@", theString); | |
} | |
int main(int argc, const char * argv[]) | |
{ | |
@autoreleasepool { | |
NSMutableString *aString = [[NSMutableString alloc] initWithString:@"This is my string"]; | |
NSLog(@"String before ChangeString: %@", aString); | |
ChangeString(aString); | |
NSLog(@"String after ChangeString: %@", aString); | |
} | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment