Re: XCode not releasing nsstring
Re: XCode not releasing nsstring
- Subject: Re: XCode not releasing nsstring
- From: Dave Keck <email@hidden>
- Date: Tue, 11 Nov 2003 20:59:13 -0500
I'm really not sure about this, but just maybe...
Aren't objects only released at the end of an event loop? I think
something that would work as expected would consist of a global
NSString, where when you click a button it sets its value to "test
string" and then releases it, then when you click another button it
checks to see if the NSString is nil, which I think it should be (it
should have been released once the method that sets the NSString's
value exists, or something around there).
The other thing I'm thinking is the string isn't actually set to nil
when you release it, it still holds an address where the old data was.
It may only "turn into" nil if you explicitly assign nil as its value.
I threw this into a new project:
NSString *releaseTest;
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."?
Bug?
Help?
_______________________________________________
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.