数组插值与取值

  • 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];

你可能感兴趣的:(存储)