Advertise Mobile SDKs Books Events Forum News Social Networking Support Us
Follow @iphonedevsdk on Twitter

Interface 2, Advanced iOS
Mockup & Code Gen
($9.99)

Make your own iPhone apps
and run them live!
(free)

Pic Frame Dynamo: Photo Editing
($0.99)

Abiliator
($1.99)

Want your application or service advertised on iPhone Dev SDK?

Go Back   iPhone Dev SDK Forum > iPhone SDK Development Forums > iPhone SDK Development

Reply
 
LinkBack Thread Tools Display Modes
Old 08-02-2010, 09:18 AM   #1 (permalink)
Registered Member
 
Join Date: Jun 2010
Location: Michigan, United States
Posts: 132
natronp is on a distinguished road
Default ownership of string within custom class

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...
natronp is offline   Reply With Quote
Reply

Bookmarks

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



» Advertisements
» Online Users: 325
8 members and 317 guests
alexP, gordo26, headkaze, mistergreen2011, nobstudio, rayjeong, Sloshmonster, stanny
Most users ever online was 1,387, 04-10-2012 at 04:21 AM.
» Stats
Members: 175,655
Threads: 94,116
Posts: 402,889
Top Poster: BrianSlick (7,990)
Welcome to our newest member, pungs
Powered by vBadvanced CMPS v3.1.0

All times are GMT -5. The time now is 11:20 PM.
Powered by vBulletin® Version 3.8.0
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.3.0