I have a simple question. If I am declaring NSString (ref type) as shown below:
NSString *johnsMoney = @\"200\";
NSString *marysMoney = johnsMoney;
johnsMoney
and marysMoney
are both pointers to strings.
When you write johnsMoney = @"100"
, it now points to a different string. This doesn't change marysMoney
which still points to the original string.
If you were using NSMutableString
, and you did [johnsMoney setString:@"100"]
, then it would change the underlying data (to which both variables would still be pointing).