- 把CGPoint放入数组的过程:
NSArray *array=[NSArray arrayWithObjects:NSStringFromCGPoint(0.0f,0.0f),NSStringFromCGPoint(0.0f,0.0f),nil];
- 从数组中取值的过程:
CGPoint point=CGPointFromNSString([array objectAtIndex:2]);
-
用NSValue进行统一存储也不错,NSValue可以包装任何值
NSRect *rect = NSRectMake(1,2,20,30);
NSValue *value = [NSValue valueWithByte:&rect ObjCType:@encode(NSRect)];
[array addObject:value];
NSRect *getRect = [NSValue getValue:&rect];
本文介绍了如何使用NSString和NSValue来存储和读取CGPoint类型的数据。通过具体示例展示了将CGPoint转换为NSString并存入数组的方法,以及利用NSValue进行统一存储的技巧。
469

被折叠的 条评论
为什么被折叠?



