• 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: Is @"constantstring" pointer equal to @"constantstring" a guarantee?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Is @"constantstring" pointer equal to @"constantstring" a guarantee?


  • Subject: Re: Is @"constantstring" pointer equal to @"constantstring" a guarantee?
  • From: Ken Thomases <email@hidden>
  • Date: Thu, 27 Mar 2008 21:49:29 -0500

On Mar 27, 2008, at 9:41 PM, Kyle Sluder wrote:

But it still makes sense to me that when I'm providing NSString
constants to be used as they are in the case of an NSError's userInfo
dictionary, for example, that pointer comparison is still valid.  Of
course I wouldn't do it for places where I expect arbitrarily-provided
strings to be passed to my method, but I typically make my string
constants opaque.

Is this just in general a Bad Idea(TM)?

I think so. There's no telling if somebody has copied the string on its way from where you stuff it in the dictionary to where you're comparing it. Even if immutable string classes optimize copy... methods to be the equivalent of retain, there's no guarantee that somebody didn't do stringWithString: or whatever to circumvent that.


Cheers,
Ken
_______________________________________________

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: 
 >Is @"constantstring" pointer equal to @"constantstring" a guarantee? (From: Nathan Vander Wilt <email@hidden>)
 >Re: Is @"constantstring" pointer equal to @"constantstring" a guarantee? (From: Jens Alfke <email@hidden>)
 >Re: Is @"constantstring" pointer equal to @"constantstring" a guarantee? (From: "Kyle Sluder" <email@hidden>)

  • Prev by Date: Re: Subverting the first responder chain
  • Next by Date: Re: Is @"constantstring" pointer equal to @"constantstring" a guarantee?
  • Previous by thread: Re: Is @"constantstring" pointer equal to @"constantstring" a guarantee?
  • Next by thread: Re: Is @"constantstring" pointer equal to @"constantstring" a guarantee?
  • Index(es):
    • Date
    • Thread