Re: defined but not used error
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