开发者

Property (retain) object being released without ever being flagged for release

I'm at my wits end. I'm trying to debug a crash, and finally I manage to track it down. My 'minutesLeft' variable is somehow being released.

Problem is, I never set it to release, and the property is set to retain. I can't figure out what is going on!

Using the zombie variable, I got the following message: *** -[CFNumber intValue]: message sent to deallocated instance 0x728fdd0

and tracked it down to the following line of code:

NSLog(@"MeterViewController minutesLeft %i", [minutesLeft intV开发者_Python百科alue]);

The problem is when I declare the property... @property (nonatomic, retain) NSNumber *minutesLeft; So the property should be handling the retain for me!

The value is set using...

minutesLeft=[NSNumber numberWithInt:row];

and...

minutesLeft=[NSNumber numberWithInt:(((timeLeft)/60)%60)];

For dealloc and viewDidUnload I have

self.minutesLeft=nil;

but since I'm not leaving the view, those shouldn't be effecting anything.

Anyone have any ideas?


You are setting the local variable that is the backing for the property, not the property itself. Thus it doesn't get retained. Try:

self.minutesLeft = [NSNumber numberWithInt:row]

or

self.minutesLeft = [NSNumber numberWithInt:(((timeLeft)/60)%60)];

(Note the self.)

You are doing it correctly when deallocating though (setting self.minutesLeft = nil).

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜