• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Core Data/Cocoa Bindings: best practice for using strings in code?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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
  • Follow-Ups:
    • Re: Core Data/Cocoa Bindings: best practice for using strings in code?
      • From: Fritz Anderson <email@hidden>
    • Re: Core Data/Cocoa Bindings: best practice for using strings in code?
      • From: Óscar Morales Vivó <email@hidden>
References: 
 >Core Data/Cocoa Bindings: best practice for using strings in code? (From: Michael McCracken <email@hidden>)
 >Re: Core Data/Cocoa Bindings: best practice for using strings in code? (From: Óscar Morales Vivó <email@hidden>)

  • Prev by Date: Re: Core Data: transient attributes require bogus type to quiet compiler?
  • Next by Date: NSXMLDocument: apply XSLT with arguments
  • Previous by thread: Re: Core Data/Cocoa Bindings: best practice for using strings in code?
  • Next by thread: Re: Core Data/Cocoa Bindings: best practice for using strings in code?
  • Index(es):
    • Date
    • Thread