Re: Is @"constantstring" pointer equal to @"constantstring" a guarantee?
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