Initializing object pointers to nil
Initializing object pointers to nil
- Subject: Initializing object pointers to nil
- From: Jeffrey Mattox <email@hidden>
- Date: Thu, 17 Apr 2003 03:10:56 -0500
I know that [nil release] is allowed (although I can't find
documentation), but am I guaranteed that an object pointer will be
nil if it hasn't been explicitly set? That is, must I declare
variables this way:
NSArray *myArray = nil;
-(void)myMethod
{
NSString *tempString = nil;
// ... code here, maybe alloc-ing and using tempString and myArray
[tempString release]; // might be [nil release]
[myArray release]; // might be [nil release]
}
as opposed to this:
NSArray *myArray;
NSString *tempString;
In general, what are the ramifications of initializing variables
where they are declared as opposed to in-line, in the code itself?
Jeff
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.