Re: Making my own constants for Cocoa structs
Re: Making my own constants for Cocoa structs
- Subject: Re: Making my own constants for Cocoa structs
- From: Alastair Houghton <email@hidden>
- Date: Fri, 3 Aug 2007 17:55:56 +0100
On 3 Aug 2007, at 17:46, Paul Bruneau wrote:
On Aug 3, 2007, at 12:11 PM, Scott Ribe wrote:
Also note that there are macros defined: NSMakeRect, NSMakePoint, and
NSMakeSize. These are documented in a place you probably haven't
yet found,
because they're lumped together with a lot of simple functions
that don't
belong to any class, while most of the Coco docs are arranged around
classes. Just search on any of those macros...
I knew already about those macros which I have used in my code, but
I couldn't get them to work outside of a method so that I could use
them more globally. But I might have just made a simple error.
I think that's because they aren't macros---they're inline
functions. As a result, you can't use them as initialiser
expressions for global variables in a C or ObjC source file (since it
isn't clear when the function would be called). You can, of course,
initialise global variables in a +initialize method as a workaround,
though you can't then declare them const. Or you can write them with
braces, as Scott and Stephane suggested.
Kind regards,
Alastair.
--
http://alastairs-place.net
_______________________________________________
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