I have a simple question. If I am declaring NSString (ref type) as shown below:
NSString *johnsMoney = @\"200\";
NSString *marysMoney = johnsMoney;
No. Remember you are dealing with pointers. So when you do
johnsMoney = @"100";
You are setting the johnsMoney pointer to a different memory address which contains the @"100" value. marysMoney still points to the original address with the @"200" value.
NSString is value type. (Immutable).
And there is a concept of sting iterning as well.
NSString *johnsMoney = @"200";
NSString *marysMoney = johnsMoney;
johnsMoney = @"100";
So when you are changing the string of johnsMoney, its now pointing to new memory address. But marysMoney still having old sting (i.e. 200) so pointing to previous address.
Go to this tutorial, you will learn really new things. https://nshipster.com/equality/