Skip to content

Instantly share code, notes, and snippets.

@shto
Created March 14, 2014 15:02
Show Gist options
  • Save shto/9549405 to your computer and use it in GitHub Desktop.
Save shto/9549405 to your computer and use it in GitHub Desktop.
Example of passing by reference in Objective-C
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