Okay, sorry about this since I think I asked about it previously, but I 
forgot...

If a method (or even a C-style function) returns (NSString *), and I have a 
method/function like:

-(NSString *)bool2String:(BOOL)b
{
if (!b)
  {
  return @"NO";
  }
return @"YES";
}

is there ever a situation in which (properly written) client code could call 
this and trip over the memory  management rules? (as opposed to:

-(NSString *)bool2String(BOOL)b
{
if (!b)
  {
  return [NSString stringWithFormat:@"%@", @"NO");
  }
return [NSString stringWithFormat:@"%@", @"YES");
}

which, IIRC, would return an autoreleased NSString, correct?)
  This is, is a literal NSString autoreleased, or retained? Does it matter? I 
would guess that literal NSStrings are (effectively) retained, since they're 
not going anywhere (they're literal constants, after all), but they're not 
obtained by "New", "alloc", or "copy", which - according to the memory 
management rules, means you should retain them because they were autoreleased. 
Which is true?



_______________________________________________

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Reply via email to