【发布时间】:2010-04-06 14:04:53
【问题描述】:
for ( tempI = 0; tempI < 10; tempI++ )
{
tempJ = 1;
NSArray *objectsForArray = [NSArray arrayWithObjects:@"array[tempI][tempJ]", @"array[tempI][tempJ+1]", @"array[tempI][tempJ+2]", nil];
}
我可以像上面那样写代码吗?我需要在NSArray 中存储一个浮点值(array[][])。我可以吗?
我的问题是,我有一个矩阵作为
1.0 0.4 0.3 0.5
2.0 0.4 0.5 0.5
3.0 4.3 4.9 0.5
我需要使用 1.0, 2.0 3.0 检索值 (0.4, 0.3, 0.5)。我该如何使用 NSDictionary?
谢谢你
for( tempI = 0; tempI < 5; tempI++)
{
NSDictionary *dictionary[tempI] = [ [NSDictionary alloc] initWithObjects:@"array[tempI][tempI + 1]", @"array[tempI][tempI + 2]", @"array[tempI][tempI + 3]", @"array[tempI][tempI + 4]", @"array[tempI][tempI + 5]", nil];
}
我可以这样写吗? Objective C 接受它吗?
我收到一个错误
error: variable-sized object may not be initialized
【问题讨论】:
-
请问您为什么要将3D矩阵存储到NSArray中?
标签: objective-c cocoa-touch cocos2d-iphone