• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: XCode not releasing nsstring
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: XCode not releasing nsstring


  • Subject: Re: XCode not releasing nsstring
  • From: Ben Dougall <email@hidden>
  • Date: Wed, 12 Nov 2003 02:34:23 +0000

On Wednesday, November 12, 2003, at 01:20 am, Justin Lundy wrote:

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."?

no i don't think it should. when you release an object what's going to make the pointer you have to it go to a nil value? nothing, unless you manually do that. the pointer will still have the address of the now possibly defunct object. that's what all the SIGSEGV (if that's the right word) errors often are - a message being sent to an object that's no longer there. if you set a pointer to nil manually having released the object it points to and then send a message to that, nothing will happen (which i believe is good practice although i never bother with that myself). a pointer is just a local variable holding a value, so when you release the object it points to there's no reason for that value to be set to nil. could be wrong on all that but that's the way i see it.
_______________________________________________
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.
References: 
 >XCode not releasing nsstring (From: Justin Lundy <email@hidden>)

  • Prev by Date: Darker background
  • Next by Date: Re: XCode not releasing nsstring
  • Previous by thread: Re: XCode not releasing nsstring
  • Next by thread: Re: XCode not releasing nsstring
  • Index(es):
    • Date
    • Thread