Setting pointer to nil
Setting pointer to nil
- Subject: Setting pointer to nil
- From: Jeff LaMarche <email@hidden>
- Date: Tue, 20 Dec 2005 17:39:57 -0500
I've noticed that with Xcode 2.2, the Core Data Application template
has been updated. The new application delegate class template been
given a new dealloc method:
- (void) dealloc
{
[managedObjectContext release], managedObjectContext = nil;
[persistentStoreCoordinator release], persistentStoreCoordinator
= nil;
[managedObjectModel release], managedObjectModel = nil;
[super dealloc];
}
I've never seen pointers set to nil like this in Objective-C. I don't
recall any of the books I've got recommending doing this in a
dealloc. I HAVE seen it done a lot in Java to blue in the garbage
collector to the fact that you're done with an object.
Now that I see it, it does seem like a good idea - it seems like this
practice would prevent sending messages to released objects, instead
just sending a harmless message to nil (although it could potentially
mask problems in some cases), but I can't help but wondering if this
isn't the first sign that Apple's planning on giving us an Objective-
C garbage collector at some point.
Jeff
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden