Re: Setting pointer to nil
Re: Setting pointer to nil
- Subject: Re: Setting pointer to nil
- From: John Stiles <email@hidden>
- Date: Tue, 20 Dec 2005 14:46:34 -0800
On Dec 20, 2005, at 2:39 PM, Jeff LaMarche wrote:
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.
There are stronger hints than that:
http://developer.apple.com/documentation/DeveloperTools/gcc-4.0.1/gcc/
Garbage-Collection.html
Apple has been working on garbage-collected Cocoa for a while; I
think it missed the 10.4 deadline, though (kind of like scalable UI).
_______________________________________________
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