相关疑难解决方法(0)

如何在NSArray中存储浮点值?

for ( tempI = 0; tempI < 10; tempI++ )  
{
    tempJ = 1;
    NSArray *objectsForArray = [NSArray arrayWithObjects:@"array[tempI][tempJ]", @"array[tempI][tempJ+1]",  @"array[tempI][tempJ+2]", nil];
}
Run Code Online (Sandbox Code Playgroud)

我可以像上面那样编写代码吗?我需要存储的浮点值(array[][])NSArray.我可以做吗 ?
我的问题是,我有一个矩阵作为

1.0   0.4   0.3   0.5  
2.0   0.4   0.5   0.5  
3.0   4.3   4.9   0.5  
Run Code Online (Sandbox Code Playgroud)

我需要使用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];
}
Run Code Online (Sandbox Code Playgroud)

我可以这样写吗?Objective C是否接受它?

我收到错误了 …

cocoa-touch objective-c cocos2d-iphone

8
推荐指数
1
解决办法
2万
查看次数

标签 统计

cocoa-touch ×1

cocos2d-iphone ×1

objective-c ×1