Re: XCode not releasing nsstring
Re: XCode not releasing nsstring
- Subject: Re: XCode not releasing nsstring
- From: Clark Cox <email@hidden>
- Date: Tue, 11 Nov 2003 21:46:27 -0500
On Nov 11, 2003, at 20:20, Justin Lundy wrote:
>
I threw this into a new project:
>
>
NSString *releaseTest;
This is undefined, you haven't initialized releaseTest to anything. It
might be nil, it might not be, it might be anything.
>
if (releaseTest != nil) NSLog(@"A: releaseTest NOT nil.");
>
if (releaseTest == nil) NSLog(@"A: releaseTest nil.");
>
>
releaseTest = [[NSString alloc] initWithString:@"test string"];
>
>
if (releaseTest != nil) NSLog(@"B: releaseTest NOT nil.");
>
if (releaseTest == nil) NSLog(@"B: releaseTest nil.");
>
>
[releaseTest release];
>
>
if (releaseTest != nil) NSLog(@"C: releaseTest NOT nil.");
>
if (releaseTest == nil) NSLog(@"C: releaseTest nil.");
>
>
and guess what the log said?
>
>
A: releaseTest nil.
>
B: releaseTest NOT nil.
>
C: releaseTest NOT nil.
>
>
Call me crazy, but shouldn't the last one say "C: releaseTest nil."?
No, releasing an object doesn't set that variable to nil. If you want
the variable to be nil, then you must set it yourself
--
Clark S. Cox III
email@hidden
http://homepage.mac.com/clarkcox3/blog/B1196589870/index.html
[demime 0.98b removed an attachment of type application/pkcs7-signature which had a name of smime.p7s]
_______________________________________________
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.