Last active
December 20, 2015 01:29
-
-
Save brockboland/6049308 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
-(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". |
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
Also check out the NSString API:
http://developer.apple.com/library/ios/#documentation/Cocoa/Reference/Foundation/Classes/NSString_Class/Reference/NSString.html
The stringWithString: method applies a copy to the string you're giving as reference:
Parameters
aString
The string from which to copy characters. This value must not be nil.