Skip to content

Instantly share code, notes, and snippets.

@BigAB
Created August 8, 2013 16:36
Show Gist options
  • Select an option

  • Save BigAB/6186275 to your computer and use it in GitHub Desktop.

Select an option

Save BigAB/6186275 to your computer and use it in GitHub Desktop.
A convenience thing, just some null types for common structs and a way to check for them. Idea from this SO: http://stackoverflow.com/questions/11987142/sending-nil-to-cgpoint-type-parameter
const CGPoint ABCGPointNull = {(CGFloat)NAN, (CGFloat)NAN};
const UIOffset ABUIOffsetNull = {(CGFloat)NAN, (CGFloat)NAN};
const CGSize ABCGSizeNull = {(CGFloat)NAN, (CGFloat)NAN};
BOOL ABCGPointIsNull( CGPoint point ){
return isnan(point.x) && isnan(point.y);
}
BOOL ABUIOffsetIsNull( UIOffset offset ){
return isnan(offset.horizontal) && isnan(offset.vertical);
}
BOOL ABCGSizeIsNull( CGSize size ){
return isnan(size.width) && isnan(size.height);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment