I tried to understand dereferencing in Objective-C and wrote two methods below.
-(void)alterStringModelOne:(NSMutableString**)string{ NSMutableString *str = [NSMutableString stringWithString:@"New string by string = &str"]; string = &str;
In the above example, ModelOne does not work while ModelTwo is running. How do these two statements differ? Can someone help me understand? Thanks.
Edit: tracking their address and type
myStr = b260 type * CFString
---> Included in the one method model
string = d9c4 type ** NSMutableString // Parameter
str = f750 of * CFString // after creating str
string = d97c type ** NSMutableString // After assignment: string = & str;
-> returns
myStr = b260 * CFString
-> Introduces a method model two
string = d9c4 type ** NSMutableString // Parameter
str = 0bc0 of * CFString // after creating str
string = 0bc0 of type * CFString // After assignment: * string = str;
-> Leaf Method
myStr = 0bc0 type * CFString
source share