• 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: Sebastian Nowicki <email@hidden>
  • Date: Tue, 27 May 2008 02:09:58 +0800


On 27/05/2008, at 12:22 AM, Jens Alfke wrote:


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_______________________________________________


Is this usually how notification names are defined? I was wondering how people did it, so I search using google's code search and found a few examples of that method, but they weren't defined const. Currently I have something like:

// Header:
extern NSString * MyActionDidFinishNotification;
// Implementation:
NSString * MyActionDidFinishNotification = @"MyActionDidFinishNotification";

Is that how people would normally do it?

Sorry to go on a bit of a tangent, I'm just curious.

Thanks,
Sebastian Nowicki

_______________________________________________

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: Scott Ribe <email@hidden>
    • Re: defined but not used error
      • From: Jens Alfke <email@hidden>
References: 
 >defined but not used error (From: "John Love" <email@hidden>)
 >Re: defined but not used error (From: Jens Alfke <email@hidden>)

  • Prev by Date: assignment in if clause (was: alternate pattern for object initializers)
  • Next by Date: Re: defined but not used error
  • Previous by thread: Re: defined but not used error
  • Next by thread: Re: defined but not used error
  • Index(es):
    • Date
    • Thread