Re: Core Data/Cocoa Bindings: best practice for using strings in code?
Re: Core Data/Cocoa Bindings: best practice for using strings in code?
- Subject: Re: Core Data/Cocoa Bindings: best practice for using strings in code?
- From: Jed Soane <email@hidden>
- Date: Thu, 14 Jul 2005 11:29:13 +1200
This raises another question I've been meaning to ask. In our code we
have an annoying problem. When we declare the keys as constant
strings we get warnings, which make compiling with "treat warnings as
errors" impossible to use. For example, the code:
const NSString* CLIP_NAME_KEY = @"clipName";
[clip setValue:clipName forKey:CLIP_NAME_KEY];
causes this error:
ClipList.m:638: warning: passing argument 2 of 'setValue:forKey:'
discards qualifiers from pointer target type
Does anyone have any ideas to get around the warning (with removing
the const modifier or disabling the warning:)
Cheers
Jed
On Jul 14, 2005, at 8:57 AM, Óscar Morales Vivó wrote:
I think the usual recommendation is to use constant NSString
objects. Put them in the code file, and declare them as 'extern' in
the header file if you need to. Examples from my code:
In header OMVPerson.h:
extern NSString *OMVPersonParentsKey;
In code file OMVPerson.m:
NSString *OMVPersonParentsKey = @"parents";
_______________________________________________
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