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

Mockup & CodeGen, iPhone & iPad
($9.99)

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

Manu
($0.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 09-06-2009, 02:15 PM   #1 (permalink)
Registered Member
 
Join Date: Sep 2009
Posts: 4
Default Problem with object being de-alloced

Hi All,

bit of a new iphone / objective-c coder, but long time hacker . I'm have a strange problem with an object that is getting destroyed and I can't work out why

I create a new object:

Code:
myUploadRootViewController = [[uploadRootViewController alloc  ] initWithNibName:@"uploadRootViewController" bundle:nil];
and then when I come to use it I get an 'EXC_BAD_ACCESS' which appears to be because as soon as the view controller is created it's dealloc method is called. (proved with an NSLog statment)

Now given I've called alloc and don't call release it anywhere or add it to an autorelease pool, how/why is it getting released ?

As far as I understand if I alloc an object I'm responsibe for a release and/or memory leak

Any pointers welcome...


sal
sal_park is offline   Reply With Quote
Old 09-06-2009, 03:08 PM   #2 (permalink)
Registered Member
 
JonnyThunder's Avatar
 
Join Date: Jul 2009
Posts: 40
Default

Yes, if you alloc an object you are responsible for releasing it. Are you sure it's this which is being deallocated, and not something within this class?
JonnyThunder is offline   Reply With Quote
Old 09-06-2009, 03:49 PM   #3 (permalink)
Registered Member
 
Join Date: Sep 2009
Posts: 4
Default

Quote:
Originally Posted by JonnyThunder View Post
Yes, if you alloc an object you are responsible for releasing it. Are you sure it's this which is being deallocated, and not something within this class?
Hi Jonny,

spot on advice - the object being created here:
Code:
self.myUploadRootViewController = 
   [[uploadRootViewController alloc  ] 
       initWithNibName:@"uploadRootViewController" bundle:nil];
   NSLog(@"hash is [%i]",[myUploadRootViewController hash]);
Is not that same object instance that is being destroyed here:
Code:
- (void)dealloc {
	NSLog(@"****** uploadRootViewController being dealloced");
	NSLog(@"hash is [%i]",[self hash]);
    [super dealloc];
}
So given I've only created 1 object, where is the other instance coming from ? is it being created from the info in the nib ?

thanks

sal
sal_park is offline   Reply With Quote
Old 09-06-2009, 07:27 PM   #4 (permalink)
Registered Member
 
Join Date: Apr 2009
Posts: 536
Default

I'm guessing you have an instance of uploadRootViewController inside that nib and you're using that to make some connections. That's probably not what you want. Most likely, you want to make your connections to "File's Owner" instead.
eddietr is offline   Reply With Quote
Old 09-07-2009, 03:31 AM   #5 (permalink)
Registered Member
 
Join Date: Sep 2009
Posts: 4
Default

Hi Eddietr,

Quote:
Originally Posted by eddietr View Post
I'm guessing you have an instance of uploadRootViewController inside that nib and you're using that to make some connections. That's probably not what you want. Most likely, you want to make your connections to "File's Owner" instead.
Thanks - your guess is 100% correct - I'd attached the connections from the button throwing the error to the uploadRootViewController instance in the nib, not the file owners. I'm now very happy it is working !

thanks for the help guys, very much appreciated.


sal
sal_park is offline   Reply With Quote
Reply

Bookmarks

Tags
alloc, dealloc, exc_bad_access

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
» Stats
Members: 158,884
Threads: 89,229
Posts: 380,763
Top Poster: BrianSlick (7,129)
Welcome to our newest member, karlam963
Powered by vBadvanced CMPS v3.1.0

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