• 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: CGPoint wrapper?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: CGPoint wrapper?


  • Subject: Re: CGPoint wrapper?
  • From: Jonathan Dann <email@hidden>
  • Date: Thu, 23 Oct 2008 13:07:37 +0200

If you're targeting Leopard then you can use the NS_BUILD_32_LIKE_64 flag and use NSRect/Point/Size and CGRect/Point/Size interchangeably without the cast or the inline conversion functions. Here's a how-to http://theocacao.com/document.page/552

Jonathan

http://espresso-served-here.com

On 23 Oct 2008, at 09:06, Ken Ferry wrote:

On Wed, Oct 22, 2008 at 9:09 PM, Graff <email@hidden> wrote:

On Oct 22, 2008, at 5:49 PM, DKJ wrote:

Is there some straightforward way of wrapping a CGPoint so I can put
it in an NSArray? I don't want to use a C array because I want to have
fast enumeration available. Or should I just write a simple NSPoint -
CGPoint conversion method?



NSPoint and CGPoint are structs that are essentially the same. You can
convert between them with a simple cast:


NSPoint point = *(NSPoint *)&myCGPoint;

<
http://developer.apple.com/documentation/Cocoa/Conceptual/CocoaDrawingGuide/QuartzOpenGL/chapter_10_section_2.html



You can also use the function NSPointFromCGPoint() which does the exact
same thing for you:


NSPoint point = NSPointFromCGPoint(myCGPoint);

(Declared in NSGeometry.h)


The function is actually implemented a bit better than the cast above, in
that the function does not violate strict aliasing[1].


-Ken

[1]:
http://www.cellperformance.com/mike_acton/2006/06/understanding_strict_aliasing.html
_______________________________________________

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

_______________________________________________

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


References: 
 >Re: CGPoint wrapper? (From: Graff <email@hidden>)
 >Re: CGPoint wrapper? (From: "Ken Ferry" <email@hidden>)

  • Prev by Date: CocoaHeads chapter Bonn (Germany) Kickoff TODAY
  • Next by Date: Re: Using Core Animation to animate view properties?
  • Previous by thread: Re: CGPoint wrapper?
  • Next by thread: Re: CGPoint wrapper?
  • Index(es):
    • Date
    • Thread