【发布时间】:2012-07-22 23:41:00
【问题描述】:
我创建了一个 CGpoints 的 NSMUtableArray,并通过将它们子类化为 NSValue 来存储它们,但我无法获取这些值。这就是我所做的。
CGPoint graphPoint;
NSMutableArray *pointValues = [[NSMutableArray alloc] init];
for( int x =0;x<5; x++)
{
NSDictionary* xValue = [NSDictionary dictionaryWithObject:[NSNumber numberWithInt:x] forKey:@"X"];
graphPoint.x =x;
graphPoint.y = [CalculatorBrain runProgram: self.graphingPoint usingVariableValues:xValue];
[pointValues addObject:[NSValue valueWithCGPoint:graphPoint]];
}
我尝试使用它来获取值,但我只是返回 null
for( int x=0; x<5; x++) {
NSValue *val = [pointValues objectAtIndex:x];
CGPoint point = [val CGpointValue];
NSLog(@"Points = %@", point);
}
【问题讨论】:
-
代码不崩溃真是奇迹。
标签: objective-c xcode nsmutablearray cgpoint nsvalue