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 05-14-2010, 04:35 AM   #1 (permalink)
Registered Member
 
Join Date: May 2010
Posts: 2
santhoshbabun is on a distinguished road
Post Objc Msg error when i release mutable array which can have another array

I am developing an application in which one of the main object store Mutable array of objects...

Code:
@interface MainObject : NSObject {
	
	NSMutableArray *subObject;

}

@property(nonatomic,retain) NSMutableArray * subObject;

Sub Object is as follows

Code:
@interface SubObject : NSObject {
	
	NSMutableArray *finalObject;
	NSString *somestring;
}

@property (nonatomic,retain) NSMutableArray * finalObject;
@property (nonatomic,retain) NSString * somestring;

I have a table view and based on selection in there i will fill in the MainObject and when user goes back and do a diffrent selection i query the sql and need to store diffrent object...

I am trying to release it and create a new object and store the new values in the main object....

But it is failing in the dealloc of the SubObject with objc_msgSend error..

When i debugged i found that the as soon as the finalObject in the SubObject Class is released its other member somestring is also getting released....Although the address for the two are not the same.

Can someone plz help me to resolve this...

Thanks in Advance
Santhosh
santhoshbabun is offline   Reply With Quote
Old 05-25-2010, 05:47 AM   #2 (permalink)
Registered Member
 
Join Date: May 2010
Posts: 2
santhoshbabun is on a distinguished road
Default Can some one plz help me resolve this.... Attaching the objects....

I have attached the code base..... with the relavant classes. plz help me to resolve this....
Attached Files
File Type: zip ControllerandModel.zip (17.6 KB, 2 views)
santhoshbabun is offline   Reply With Quote
Old 05-25-2010, 09:24 AM   #3 (permalink)
Registered Member
iPhone Dev SDK Supporter
 
smasher's Avatar
 
Join Date: Jul 2008
Location: San Mateo, CA (San Fran)
Posts: 3,858
smasher will become famous soon enough
Default

Which object is failing in the dealloc? I can't find MainObject and SubObject in your project, so I don't know where to start looking.

You should be able to tell which line in the dealloc is causing the crash - is it [finalObject release] or [somestring release]? That will help you narrow your search also.
__________________

Free Games!

Last edited by smasher; 05-25-2010 at 09:26 AM.
smasher is offline   Reply With Quote
Old 05-25-2010, 02:13 PM   #4 (permalink)
Senior Member
iPhone Dev SDK Supporter
 
Join Date: Jan 2010
Location: Issaquah, WA
Age: 42
Posts: 1,244
dljeffery is on a distinguished road
Default

You shouldn't be calling [super dealloc] at the top of your dealloc implementations. That should be at the bottom, after you're done releasing your own stuff.

I don't know if it will actually cause any problems... very light testing on my own code, modified to put [super dealloc] at the top, didn't result in crashes. But you should still fix it. Honestly, it *feels* like putting it at the top of your dealloc should cause crashes, even though I didn't happen to hit any when trying it.

Also, try setting NSZombieEnabled to YES. And take a look at this as well:

Hamster Emporium: [objc explain]: So you crashed in objc_msgSend()
__________________
Recall It! Tag your notes. Tag your photos. Tag your thoughts. Tag your life.

Recall It! for iPad

http://www.dljeffery.com
dljeffery is offline   Reply With Quote
Reply

Bookmarks

Tags
dealloc, memmory management, mutablearray, release

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: 313
11 members and 302 guests
Abidullah, ajay123123, Fstuff, guusleijsten, HemiMG, jbro, n00b, newDev, pkIDSF, Sami Gh, Steven.C
Most users ever online was 1,387, 04-10-2012 at 04:21 AM.
» Stats
Members: 175,648
Threads: 94,113
Posts: 402,877
Top Poster: BrianSlick (7,990)
Welcome to our newest member, brandon6031
Powered by vBadvanced CMPS v3.1.0

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