• 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: defined but not used error
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: defined but not used error


  • Subject: Re: defined but not used error
  • From: Jens Alfke <email@hidden>
  • Date: Mon, 26 May 2008 09:22:48 -0700


On 26 May '08, at 9:09 AM, John Love wrote:

I want the
StatusController.h file to list the various possible messages; e.g.,

static NSString *openMsg = @"Open a new Spreadsheet";
...
However, the Cocoa compiler will present me with Warning: whatever defined
but not used.

By declaring them in the .h file, you get copies of them in every file that includes it. Probably not what you wanted.


What probably makes the most sense is to move the declarations into StatusController.m, since you're probably only using the strings from within that class.

If you need the strings to be available from a header, do it like this:

// in StatusController.h:
	extern NSString* openMsg const;

// in StatusController.m:
NSString *openMsg const = @"Open a new Spreadsheet";

(The 'const' declaration is so that you can't accidentally assign a new value to openMsg.)

—Jens

Attachment: smime.p7s
Description: S/MIME cryptographic signature

_______________________________________________

Cocoa-dev mailing list (email@hidden)

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:

This email sent to email@hidden

  • Follow-Ups:
    • Re: defined but not used error
      • From: Sebastian Nowicki <email@hidden>
References: 
 >defined but not used error (From: "John Love" <email@hidden>)

  • Prev by Date: Re: defined but not used error
  • Next by Date: Re: Can't get file type code using [fileAttr valueForKey:NSFileHFSTypeCode]
  • Previous by thread: Re: defined but not used error
  • Next by thread: Re: defined but not used error
  • Index(es):
    • Date
    • Thread