• 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: Making my own constants for Cocoa structs
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Making my own constants for Cocoa structs


  • Subject: Re: Making my own constants for Cocoa structs
  • From: Paul Bruneau <email@hidden>
  • Date: Fri, 3 Aug 2007 12:46:08 -0400

On Aug 3, 2007, at 12:11 PM, Scott Ribe wrote:

I didn't realize that these structures could be
treated the same as a C array (?).

They're simply C structs, and follow the standard C syntax for initialization.

Note that in some versions of C, const NSRect myConstRect= {1,2,3,4}; will
give a warning, because actually using the layout of the structure is
preferred, as in const NSRect myConstRect={{1,2},{3,4}}; since an NSRect is
an NSPoint and NSSize.


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...

Thank you Scott!

That is a great description. My problem is that I am almost completely ignorant of C structs, never having programmed C before. You know how some people have a hard time leaving C structs behind in order to switch to cocoa objects? That is not one of my problems :)

I will read up more on C structs.

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.
_______________________________________________


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: Making my own constants for Cocoa structs
      • From: Alastair Houghton <email@hidden>
References: 
 >Re: Making my own constants for Cocoa structs (From: Scott Ribe <email@hidden>)

  • Prev by Date: Re: [OT] "Fluent Interface"? Welcome to NeXT
  • Next by Date: Re: [OT] "Fluent Interface"? Welcome to NeXT
  • Previous by thread: Re: Making my own constants for Cocoa structs
  • Next by thread: Re: Making my own constants for Cocoa structs
  • Index(es):
    • Date
    • Thread