Created
June 14, 2011 13:01
-
-
Save johnjohndoe/1024839 to your computer and use it in GitHub Desktop.
Convert from NSRect to CGRect
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Convert from NSRect to CGRect. | |
NSRect baz = NSMakeRect(0, 0, 100, 100); | |
CGRect foo = *(CGRect*)&baz; | |
// Include this inline function in a header file. | |
NS_INLINE CGRect CGRectMakeFromNSRect(NSRect rect) { | |
return *(CGRect*)▭ | |
} | |
// Doooooh! They already exist.. - I could not find 'em before. | |
CGRect rect2 = NSRectToCGRect(rect1); | |
NSRect rect1 = NSRectFromCGRect(rect2); | |
CGPoint point2 = NSPointToCGPoint(point1); | |
NSPoint point1 = NSPointFromCGPoint(point2); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment