Reputation: 180
This is probably a noob question, but its driving me crazy. I am developing an application that loads a subview inside the main view programatically (not in the sample code). The subview is an IEAudioChannelViewController instance, but the application crashes when i try to release the object as follows:
IEAudioChannelViewController *audiochannel = (IEAudioChannelViewController *) [sb instantiateViewControllerWithIdentifier:@"AudioChannel"];
NSLog(@"Audio channel: %@", audiochannel);
[audiochannel release]; <-- here the crash!
If i remove the release line it works,
Any idea why this happens ? (Automatic Reference counting is disabled)
Upvotes: 0
Views: 179
Reputation: 21221
You are releasing the object that is autoreleased, please remove the
[audiochannel release]
since the instantiateViewControllerWithIdentifier returns an auto released object The rules is always the same, if you dont alloc, new, retain or copy an object then dont call release on it
Upvotes: 1
Reputation: 29767
Hm. It happens because you call release
. Call release
only when you are owner of object - e.g. when alloc, copy, new, retain keywords used.
Upvotes: 2