• 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: NSString uppercaseString
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: NSString uppercaseString


  • Subject: Re: NSString uppercaseString
  • From: email@hidden
  • Date: Fri, 27 Jun 2008 15:48:22 +0200


On 27 Jun 2008, at 3:30pm, Uli Kusterer wrote:

If you read the documentation closely, you'll see that it would be perfectly valid to implement this method so the string goes away when the original (non-uppercase) string is released.

Hmmm, not sure I'd read it that way (depending on what you are reading).

According to: http://developer.apple.com/documentation/Cocoa/Conceptual/MemoryMgmt/Concepts/ObjectOwnership.html
*****
Validity of Shared Objects
Cocoa’s ownership policy specifies that received objects should remain valid throughout the scope of the calling method. It should also be possible to return a received object from the current scope without fear of it being released. It should not matter to your application that the getter method of an object returns a cached instance variable or a computed value. What matters is that the object remains valid for the time you need it.


There are exceptions to this rule. For example, collection classes do not attempt to extend the lifetime of objects placed inside them. Removing an object from a mutable array could invalidate any copies of the object previously acquired, as in the following example:

value = [array objectAtIndex:n];
[array removeObjectAtIndex:n];
// value could now be invalid.

*****

Since there is no explicit mention that uppercaseString is an exception to this, I think the string will always be valid in such cases as:

NSString* someString = [NSString alloc] initWithWhatever:whatever];

NSString* someOtherString = [someString uppercaseString];

[someString release];



Matt Gough_______________________________________________

Cocoa-dev mailing list (email@hidden)

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:
This email sent to email@hidden


References: 
 >NSString uppercaseString (From: "Sam Mo" <email@hidden>)
 >Re: NSString uppercaseString (From: Tito Ciuro <email@hidden>)
 >Re: NSString uppercaseString (From: Uli Kusterer <email@hidden>)

  • Prev by Date: Re: NSString uppercaseString
  • Next by Date: Re: NSString uppercaseString
  • Previous by thread: Re: NSString uppercaseString
  • Next by thread: Re: NSString uppercaseString
  • Index(es):
    • Date
    • Thread