typedef struct _NSRange{ NSUInteger location; NSUInteger length; }NSRange;
NSString* str = @"I love OC"; // NSRange* rg = {2, 4}; // NSRange* rg = {.location = 2, .length = 4}; NSRange* rg = NSMakeRange(2, 4); NSRange* r = [str rangOfString:@"love"];// "love"字符,从2开始,长度为4 NSRange p0 = NSRangeZero;// 判断是否相等,返回bool值
CGFloat即double typedef _NSPoint{ CGFloat x; CGFloat y; }NSPoint; typedef NSPoint CGPoint;
// CGPoint p = CGMakePoint(10, 10); CGPoint p = CGPointMake(10, 10); NSLog(@"%@", NSStringFromPoint(p)); CGPoint p0 = CGPointZero; CGPointEqualToPoint(p, p0);// 判断是否相等,返回bool值
typedef struct _NSSize{ CGFloat x; CGFloat y; }NSSize; typedef NSSize CGSize;
CGSize sz = CGSizeMake(10, 10); NSLog(@"%@", NSStringFromSize(sz)); CGSize sz0 = CGSizeZero; CGSizeEqualToSize(sz, sz0);// 判断是否相等,返回bool值
typedef struct _NSRect{ NSPoint origin; NSSize size; }NSRect; typedef NSRect CGRect;
CGRect r = CGRectMake(0, 0, 100, 50); NSLog(@"%@", NSStringFromRect(r)); CGRect r0 = CGRectZero; CGRectEqualToRect(r, r0);// 判断是否相等,返回bool值 CGRectContainsPoint(r, p);// 判断矩形是否包含点,返回bool值
原文地址:http://blog.csdn.net/xufeng0991/article/details/43387197