Re: Newbie question: constants
Re: Newbie question: constants
- Subject: Re: Newbie question: constants
- From: Tim Hart <email@hidden>
- Date: Thu, 18 Nov 2004 23:29 -0600
>It's an XCode thing in so far as I'm not sure if it explicitly asks the
>linker to remove duplicates... I have a feeling it doesn't, or at least
>didn't in earlier versions.
I'm not aware of any compiler flag at all which allows you to dictate to
the compiler to *not* remove duplicate instances of static data. I do plead
ignorance to the behavior of 'ld'.
>This only stops you changing the value kMyString points to - it doesn't
>make the string itself constant. For immutable objects, that's not so
>much an issue - for mutable ones, it is.
The string @"someString" is an immutable string. The specific case
mentioned passes muster just fine. You are absolutely correct that other
object types that do not have compile time representations create a problem.
>Of course, as I alluded the
>bigger problem with such a scenario is that your design is very poor
>(or outright wrong).
In the case of simple types or NSStrings, my design is neither poor nor
flat out wrong. There is no way to change the object 'myString' at all. By
definition, any string declared at compile time with the @"" notation is an
immutable string. Apple uses the same construct for their Cocoa constants.
Defining an NSNumber object as a constant is a bit trickier.
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden