value assigned to a property in the model class disappears in the view/controller class

后端 未结 4 542
心在旅途
心在旅途 2021-01-28 10:13

Right before my model class sends the variable stringToDisplay, NSLog shows me that it has a value. But when I try to use it in my ViewController, I just get

4条回答
  •  情书的邮戳
    2021-01-28 11:02

    I can guess that problem lies in the way you assign your stringForDisplay, eg.:

    if you use something like

    stringForDisplay_ = anotherString;
    

    setter for property doesn't fire, so you have to retain your variable yourself otherwise it'll live just until your method finishes;

    If so - use property setters, eg.:

    self.stringForDisplay = anotherString;
    

    that way ARC will do all the memory management.

提交回复
热议问题