@property/@synthesize question

后端 未结 3 937
清歌不尽
清歌不尽 2021-01-31 12:39

I\'m going through all of my documentation regarding memory management and I\'m a bit confused about something.

When you use @property, it creates getters/setters for th

3条回答
  •  慢半拍i
    慢半拍i (楼主)
    2021-01-31 13:10

    In addition to Nick's answer - synthesized getters/setters don't provide autorelease (btw, what's the big idea of doing this? Well, you can use getter as a factory, but it's not a common way in Objective C).

    Then in dealloc I see:

    self.myString = nil;

    or

    [myString release];

    or

    self.myString = nil; [myString release];

    In dealloc it doesn't really matter which form of release you're using. But the good way is to nil your fields when releasing them :) I prefer to use self.myString = nil; in dealloc

提交回复
热议问题