Re: Creation of constants
Re: Creation of constants
- Subject: Re: Creation of constants
- From: j o a r <email@hidden>
- Date: Fri, 31 Oct 2003 12:44:25 +0100
On 2003-10-31, at 11.45, Alastair J.Houghton wrote:
Well, one reason is that #define'd constants don't end-up as symbols
in the debugger on most systems.
OK, makes sense.
For string constants, you can declare an external global variable e.g.
extern const char *MY_C_STRING;
extern NSString *MY_NS_STRING;
Why did you use the const type qualifier for the (char *) and not the
(NSString *)?
When I do this:
const NSString *kMyKey = @"MyKey";
...instead of this:
const id kMyKey = @"MyKey";
...I get this warning:
MyClass.m:666: warning: passing arg 1 of `isEqualToString:'
discards qualifiers from pointer target type
...for this piece of code:
if ([key isEqualToString: kMyKey])
Why is that, and how would you fix it - by using id, or by removing
const? I notice that if I omit the const type qualifier, I no longer
get the warning - but then I also loose the benefits of using the type
qualifier.
j o a r
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.