Skip to content

Instantly share code, notes, and snippets.

@mayoff
Created May 31, 2017 15:43
Show Gist options
  • Save mayoff/08390f6d2f8a6d05b4a711cbeaf558a0 to your computer and use it in GitHub Desktop.
Save mayoff/08390f6d2f8a6d05b4a711cbeaf558a0 to your computer and use it in GitHub Desktop.
adding objc_boxable to CoreGraphics structs
@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;
}
@AlexDenisov
Copy link

Here is a little story behind https://lowlevelbits.org/nsvalue-and-boxed-expressions/ 😺

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment