Re: newbie defines and NSString problem
Re: newbie defines and NSString problem
- Subject: Re: newbie defines and NSString problem
- From: Larry Fransson <email@hidden>
- Date: Thu, 11 Mar 2004 14:54:04 -0800
On Mar 11, 2004, at 08:12, Ken Hawkins wrote:
i have a defines.h:
#define FOO "bar"
it always returns me an erro before token ";"
what am i easily overlooking?
You're overlooking the @. Whatever you define FOO to be gets inserted
verbatim wherever you put FOO. So if you try this:
#define FOO "bar"
NSString *str = [NSString stringWithString:FOO];
the compiler sees this:
NSString *str = [NSString stringWithString:"bar"];
You see, you forgot the @ - "bar" is not a valid Objective-C string
literal, so you get the compiler error.
Try this:
#define FOO @"bar"
and see if it doesn't work better.
Larry Fransson
Seattle, WA
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.