Objective C - Memory management question?

后端 未结 4 1227
-上瘾入骨i
-上瘾入骨i 2021-01-28 21:35

I know that when i have a property for an object which is set to retain or copy i must do the following.

Object *o = [[Object alloc] init];
self.myObject = o;
[o         


        
4条回答
  •  盖世英雄少女心
    2021-01-28 21:50

    What you can do is ensure you release the previously allocated object before assigning the variable holding it to a new instance (be it a retained version of another object, or a copy of it).

    If you don't define a property for it, don't use the dot syntax.

提交回复
热议问题