On Thu, Mar 27, 2008 at 10:52 PM, glenn andreas <[EMAIL PROTECTED]> wrote: > Bad Idea. > > Consider that, at some point, you move your code into a framework that > you can reuse in multiple projects. While the linker can coalesce > constant strings within a single binary, it obviously doesn't go > across multiple binaries, so suddenly code that worked fine no longer > works (and you spend days tracking it down).
That's actually the situation my question arose from. > You could do what Coca does and declare your keys as variables: > > extern NSString *NSFontAttributeName; > > In this case, if you always used NSFontAttributeName (and never > @"NSFontAttributeName") you should be OK, because all places are > basically referring to the same variable value. This, of course, > assumes that the variable is _always_ used. This is what I do. In my header, my string constants are declared extern, and defined in a source file. I figured only one instance of this symbol will exist anyway and will be resolved by dyld at runtime. Though I guess I shouldn't assume that dyld will actually resolve _MyStringKey to the same place in all cases (though why would it ever do otherwise?). > Of course, I'd be paranoid and just use isEqualToString: since that > has the fewest assumptions and is the safest (and the infinitesimal > performance penalty is completely overwhelmed by the time not spent > tracking down bugs by using "=="). Makes sense. --Kyle Sluder _______________________________________________ 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 [EMAIL PROTECTED]