我的数组:为什么此数组返回0作为对象计数?
NSMutableArray *squareLocations;
CGPoint dotOne = CGPointMake(1, 1);
[squareLocations addObject:[NSValue valueWithCGPoint:dotOne]];
CGPoint dotTwo = CGPointMake(10, 10);
[squareLocations addObject:[NSValue valueWithCGPoint:dotTwo]];
CGPoint dotThree = CGPointMake(100, 100);
[squareLocations addObject:[NSValue valueWithCGPoint:dotThree]];
int num = [squareLocations count];
for (int i = 0; i < num; i++)
{
NSValue *pointLocation = [squareLocations objectAtIndex:i];
NSLog(@"%@", pointLocation);
}
当我问squareLoctions
的对象数,则返回零?但上面要求计数我添加了三个NSValue对象?有人有主意吗?
+1正确的答案。我只是想我应该添加一个稍微冗长的答案来帮助那个家伙。 – Till 2013-03-14 02:06:55
超级有选择性+1,因为我更喜欢简短的答案。然后提问者应该研究为什么如果他们不明白就是这种情况。 – borrrden 2013-03-14 02:37:38
@borrrden对你的评论大笑:D ......你当然是对的。我只是觉得我应该浪费一分钟。 – Till 2013-03-14 02:44:35