I've been having some problems with NSDate and saving it in NSUserDefaults. It seams that every second time NSUserDefaults saves my NSDate, it can't because it is deallocated and shows this error in the log.
-[__NSDate retain]: message sent to deallocated instance 0x4c20c80
I know that NSDate allocs and deallocs in different ways to that of normal objects, but I was wondering if anyone knows if by using:
- (void)saveData
{
NSUserDefaults *data = [NSUserDefaults standardUserDefaults];
[data setObject:dateOpened forKey:@"dateOpened"];
[dData synchronize];
}
...or...
- (void)loadData
{
NSUserDefaults *data = [NSUserDefaults standardUserDefaults];
dateOpened = [data objectForKey:@"dateOpened"];
}
i am releasing my instance of NSDate and so giving it a retain count of 0 so my app cant save it again when it tries?
I am using:
@property (retain) NSDate *dateOpened;
Any idea's would be much grateful as I am going nuts trying to figure this out. I've only been learning for about 4 months or so and am so nearly finished my first app and this is a major spanner in the works!
Thanks a lot, and if you need any more code or information on what I'm doing, please let me know. :-D