Suppose I have this method:
- (void)placeView:(UIView*)theView withCenterIn:(CGPoint)centerPoint;
So I pass the view and a point to te the
You can't use nil
as a "no point" indicator, because it is only for objects, and CGPoint
is a struct
. (As dasblinkenlight has already said.)
In my geometry library, I've defined a "null" CGPoint
to use as a "no point" placeholder, and a function to test for it. Since the components of a CGPoint
are CGFloat
s, and float
s have a "invalid value" representation already -- NAN
, defined in math.h -- I think that's the best thing to use:
// Get NAN definition
#include
const CGPoint WSSCGPointNull = {(CGFloat)NAN, (CGFloat)NAN};
BOOL WSSCGPointIsNull( CGPoint point ){
return isnan(point.x) && isnan(point.y);
}