|
|
#1 |
|
releasing Objects [iPhone]
Hi all.
In my app i am populating an object (myCatalogObject)through unarchiving.... At the end,when i call release to that object, its calling the dealloc. (its OK) the dealloc is like below Code:
(void*) dealloc
{
[myMutableDictionary release];
[myMutableArray release];
}
I populate the myCatalogObject like below Code:
Catalog* myCatalogObject = [NSUnarchiver unarchive.......]; the Catalog class contains a MutableDictionary and MutableArray..... Thanks... |
|
|
|
0
|
|
|
#2 |
|
First of all, why are you using that C-style format for an Objective-C dealloc method? For example, the dash marking it as an instance method. Looks odd to me. Also, you should be calling super in your dealloc method. I would have something more like this:
Code:
- (void)dealloc {
[myMutableDictionary release];
[myMutableArray release];
[super dealloc];
}
__________________
Go outside, the graphics are amazing! |
|
|
|
0
|
|
|
#3 | |
|
Quote:
I am just unarchiving the entire object... Did u mean ... after archiving, i want to call retain to both of them? my dealloc is like below only (what u mentioned) Code:
- (void)dealloc {
[myMutableDictionary release];
[myMutableArray release];
[super dealloc];
}
|
||
|
|
0
|
|
|
#4 |
|
Oh, I see, you are archiving the entire object graph at once. Well, you still need to retain that myCatalogObject after you unarchive it, which means you need to release it at some point. Are you releasing that object as well in the dealloc: method of whatever class it belongs to (like your application controller maybe)? In other words, do you have the line [myCatalogObject release]; anywhere? Is that dealloc: method you listed the dealloc: for the Catalog class, or something else?
__________________
Go outside, the graphics are amazing! |
|
|
|
0
|
|
|
#5 | |
|
Quote:
i am calling the "[myCatalogObject release]" in my viewController, in turn that release calling the "dealloc" of Catalog (class of myCatalogObject) ... (dellaoc is calling as retainCount is 0, isnt it...thats what i want...) but in the "dealoc" of Catalog i release the dictionary and array, i got error when i call these two lines.... Do i want to retain myCatalogObject or dictionary & array ???? But if i call retain for myCatalogObject, retainCount of that while application terminating is "1", instead it is zero now (which is fine and apt...) |
||
|
|
0
|
![]() |
|
«
Previous Thread
|
Next Thread
»
| Thread Tools | Search this Thread |
| Display Modes | |
|
|
Similar Threads
|
||||
| thread | Thread Starter | Forum | Replies | Last Post |
| Who will release the iPhone 5: Steve Jobs or Tim Cook? | pchipchip | iPhone | 65 | Sep 25, 2011 05:17 PM |
| Ice Cubus - released for iPhone/IPod touch | quazarteam | iPhone and iPod touch Apps | 1 | Feb 22, 2011 04:35 AM |
| Resolved: Quick release of objects | carlosbutler | iPhone/iPad Programming | 3 | Feb 13, 2011 06:56 AM |
| When to release object and vars from memory | XcodeNewb | iPhone/iPad Programming | 8 | Feb 15, 2009 09:24 PM |
All times are GMT -5. The time now is 03:34 AM.








Linear Mode

