Skip to content

Instantly share code, notes, and snippets.

@brockboland
Last active December 20, 2015 01:29
Show Gist options
  • Save brockboland/6049308 to your computer and use it in GitHub Desktop.
Save brockboland/6049308 to your computer and use it in GitHub Desktop.
-(void) initStringValue: (NSString *) newValue {
myString = newValue;
}
-(void) changeStringValue: (NSString *) newValue {
// Something needs to change here
myString = newValue;
}
MyClass * objA = [[MyClass alloc] init];
objA.name = @"This is my name";
[anotherObj initStringValue: obj.name];
[anotherObj changeStringValue: @"This is someone else's name"];
// At this point, I would like objA.name to be set to "This is someone else's name".
@rodchile
Copy link

Brock I made a small test for something similar, and seems that it should work also for this.

NSString *stringA = @"hola";
NSString __strong **pointToStringA = &stringA; //The strong is because ARC can't determine who handle the memory for this pointer

NSLog(@"%@",stringA);
NSLog(@"%@",*pointToStringA);

stringA = @"boo";
NSLog(@"%@",stringA);
NSLog(@"%@",*pointToStringA);

2013-08-18 17:53:07.036 childViewController[2510:c07] hola
2013-08-18 17:53:07.861 childViewController[2510:c07] hola
2013-08-18 17:53:10.097 childViewController[2510:c07] boo
2013-08-18 17:53:10.694 childViewController[2510:c07] boo

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment