开发者

tableView cellForRow autoreleases my object

开发者 https://www.devze.com 2023-03-29 04:16 出处:网络
I have created an object like this : NSDictionary *listProfils; ... @property (nonatomic, retain) NSDictionary *listProfils;

I have created an object like this :

NSDictionary *listProfils;

...

@property (nonatomic, retain) NSDictionary *listProfils;

...

@synthetize listProfils

Later in the code I do set my object within the viewDidLoad method, the开发者_运维百科n make a count within the method tableView:tableViewcellForRowAtIndexPath:

The problem is that when the program read the method tableView:tableViewcellForRowAtIndexPath: , my object is already released whereas it was not in the previous method.

Does anyone know what is the problem here and why my object is released ?

Thanks in advance !


There is not enough of your code code to tell for sure what is wrong, but I'll make a guess. You probably did something like

listProfils = [NSDictionary dictionaryWith... //etc.];

and since that returns an autoreleased dictionary, which is not retained by the ivar, the dictionary will be released after a while. Better use a property reference:

self.listProfils = [NSDictionary dictionaryWith... //etc.];

That will take care of retaining the dictionary you just created and autorelease will take care of releasing the local reference.

0

精彩评论

暂无评论...
验证码 换一张
取 消