结构体不是对象,无法保存,如果需要保存该咋办?
这里需要用到:结构体与字符串的相互转换
结构体转为字符串:
NSString * string= NSStringFromCGPoint(CGPoint point);
NSString * string= NSStringFromCGVector(CGVector vector);
NSString * string= NSStringFromCGSize(CGSize size);
NSString * string= NSStringFromCGRect(CGRect rect);
NSString * string= NSStringFromUIOffset(UIOffset offset);
NSString * string= NSStringFromCGAffineTransform(CGAffineTransform transform);
NSString * string= NSStringFromUIEdgeInsets(UIEdgeInsets insets);
NSString * rangeStr=NSStringFromRange(range);
转为字符串之后想怎么存就怎么存!
还可以取出这个字符串把它打回原形!
字符串转为结构体:
CGPoint point= CGPointFromString(NSString *string);
CGVector vector= CGVectorFromString(NSString *string);
CGSize size= CGSizeFromString(NSString *string);
CGRect rect= CGRectFromString(NSString *string);
UIOffset offset= UIOffsetFromString(NSString *string);
CGAffineTransform trans= CGAffineTransformFromString(NSString *string);
UIEdgeInsets edge= UIEdgeInsetsFromString(NSString *string);
NSRange range=NSRangeFromString(rangeStr);