i have a custom class which is really just a data storage object.
For now it contains only a single NSString which i had set up as a property and released in my dealloc;
i'm using NSKeyedArchiver to store an instance of the object but getting the 'Bad Access' error:
Quote:
|
*** -[LyUser nickname]: message sent to deallocated instance 0x75174f0
|
when i push another view controller. I've found that by commenting out the release on that string within my data storage objects dealloc, that it stops the error.
Should i not be releasing the string property in the dealloc? I thought because it was created with (nonatomic,
retain) that I should release it...
here's the code i'm using that archives the object:
Code:
-(void)saveNickLocal
{
LyUser *lyU = [[LyUser alloc]init];
[self setNewUser:lyU];
[lyU release];
lyU=nil;
[[self newUser] setNickname:[self userNick] ];
NSString *archivePath = [NSTemporaryDirectory() stringByAppendingPathComponent:@"User.archive"];
BOOL *result = [NSKeyedArchiver archiveRootObject:[self newUser]
toFile:archivePath];
}
and then in another view controller later, i have this:
Code:
//temp test
LyUser *usr= [[LyUser alloc]init];
[self setUser:usr];
[usr release];
usr=nil;
NSString *archivePath = [NSTemporaryDirectory() stringByAppendingPathComponent:@"User.archive"];
self.user = [NSKeyedUnarchiver unarchiveObjectWithFile:archivePath];
NSLog(@"user nick: %@", self.user.nickname);
[[self navigationItem] setTitle:[[self user] nickname]];
does anyone spot something i'm doing that wouldn't jive with me deallocating the string within my LyUser object's dealloc?
I can't seem to get a handle on what the issue would be...