开发者

NSDate* getting corrupted after a few render cycles. Why?

开发者 https://www.devze.com 2023-01-17 19:31 出处:网络
I have a general timer with a 1.5 second interval (the render cycle). I have a class with an NSDate* member/property (nonatomic, retain).
  • I have a general timer with a 1.5 second interval (the render cycle).
  • I have a class with an NSDate* member/property (nonatomic, retain).
  • I set开发者_JS百科 this date by calling [callingClass setDate:expirationDate];

Now... a couple of render cycles this NSDate is valid. However, around the 3rd cycle the value of this variable gets corrupted, it seems.

When i set a break-point i notice that i can hover the mouse and see the data displayed properly (when its valid). But when its invalid i either see "out of scope", some weird strings (looks kinda like library file names or something), or in rare cases the debugger wont show me the value of any variable (i hate debugging in xcode).

So this is why i think this variable is getting corrupted somehow. Should i be setting this synthesized property as (nonatomic, retain)? Or should it be declared as something else?


I think i found the problem. I have a method called: - (NSDate*) getNSDateFromString:(NSString*)stringDate;

When i called this i was doing NSDate *date = [self getNSDateFromString:expirationString]; This was causing the behavior i described above.

Then i changed it to the following which eliminated the crashings:

NSDate *date = [[self getNSDateFromString:expirationString] retain]; // do something with the date here... [data release];

0

精彩评论

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