Created
May 31, 2017 15:43
-
-
Save mayoff/08390f6d2f8a6d05b4a711cbeaf558a0 to your computer and use it in GitHub Desktop.
adding objc_boxable to CoreGraphics structs
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
@import Foundation; | |
@import CoreGraphics; | |
typedef struct __attribute__((objc_boxable)) CGPoint CGPoint; | |
typedef struct __attribute__((objc_boxable)) CGSize CGSize; | |
typedef struct __attribute__((objc_boxable)) CGRect CGRect; | |
typedef struct __attribute__((objc_boxable)) CGVector CGVector; | |
int main(int argc, const char * argv[]) { | |
@autoreleasepool { | |
CGRect rect = CGRectMake(0, 0, 100, 50); | |
NSValue *boxedRect = @(rect); | |
NSLog(@"boxed: %@", boxedRect); | |
} | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Here is a little story behind https://lowlevelbits.org/nsvalue-and-boxed-expressions/ 😺