help-gnustep
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

does NSLog take ownership of the NSString it is given?


From: Dan Hitt
Subject: does NSLog take ownership of the NSString it is given?
Date: 14 Jun 2003 19:37:54 -0400

I get the impression that NSLog() RELEASEs the NSStrings
it is given.  Is this true?

For example, if i code

  NSString *message=[NSString stringWithFormat:@".... %u",3];
  NSLog(message);
  RELEASE(message);

then i will certainly get a segfault.

But if i either RETAIN the message before handing it to NSLog(),
or refrain from RELEASEing it, then i won't get a segfault.

However, i looked at the code in NSLog.m, and i don't see where this
RELEASEing could be done (e.g., in NSLogv(), for example, the argument
is reassigned in some, but not all, cases).

My understanding from the docs is that an object is created with
a retention count of 1---is this right?---but only deallocated when
the retention count hits 0.

Thanks in advance for any info, including (especially!) RTFM types,
especially with pointers to chapter and verse on exactly where
RELEASEing occurs.

dan




reply via email to

[Prev in Thread] Current Thread [Next in Thread]