Objective-C memory management, xml parser and other non-trivial examples

前端 未结 6 1589
佛祖请我去吃肉
佛祖请我去吃肉 2021-02-04 18:00

I know the basic principles about memory management (retain count, autorelease pools etc) in Cocoa, but once you go past simple retain/release, it\'s getting a bit more confusin

6条回答
  •  别跟我提以往
    2021-02-04 18:21

    @3rd question

    The line "objectArray = [self loadData]; // 1 - objectArray is instance var" isn't really a setter as it accesses the instance variable directly. To use a setter one needs to access it though self

    self.objectArray = [self loadData];
    

    ...and if your property is declared as (nonatomic, copy) the old objectArray will be released and a new will be created with a copy, thus being retained.

提交回复
热议问题