在我们编程的时候,有时候会需要打印一些NSRange,CGRect,CGPoint等结构体,但用%@打印的话会出现警告或者错误
今天我介绍一下一些这样的结构体的打印方法:
- NSString *NSStringFromCGPoint(CGPoint point);
- NSString *NSStringFromCGVector(CGVector vector);
- NSString *NSStringFromCGSize(CGSize size);
- NSString *NSStringFromCGRect(CGRect rect);
- NSString *NSStringFromCGAffineTransform(CGAffineTransform transform);
- NSString *NSStringFromUIEdgeInsets(UIEdgeInsets insets);
- NSString *NSStringFromUIOffset(UIOffset offset);
- NSString *NSStringFromSelector(SEL aSelector);
- NSString *NSStringFromClass(Class aClass);
- NSString *NSStringFromProtocol(Protocol *proto);
- NSRange NSUnionRange(NSRange range1, NSRange range2);
- NSRange NSIntersectionRange(NSRange range1, NSRange range2);
- NSString *NSStringFromRange(NSRange range);
- NSRange NSRangeFromString(NSString *aString);
比如:
- CGRect frame = CGRectMake(10, 10, 10, 10);
- NSLog(@"%@", NSStringFromCGRect(frame));