Objective-C NSString Reference Types

前端 未结 8 1262
情歌与酒
情歌与酒 2021-01-14 17:35

I have a simple question. If I am declaring NSString (ref type) as shown below:

 NSString *johnsMoney = @\"200\";
    NSString *marysMoney = johnsMoney;

           


        
8条回答
  •  星月不相逢
    2021-01-14 18:27

    In your example the local variable marysMoney maintains a strong reference to the initial johnsMoney object. When the johnsMoney property is changed, the property no longer keeps a strong reference to the original value, but that value is still kept alive by the marysMoney strong variable.

提交回复
热议问题