相关疑难解决方法(0)

Objective C相当于PHP的"变量变量"

在PHP和JavaScript中,您可以通过使用另一个变量作为其名称的一部分来动态使用变量.我不想将数组用作解决方案的一部分.这可以在Objective C中实现吗?我想做这样的事情:

for (int i=1; i<6; i++) {
        if([appRecord.answer(i) length] != 0){
            self.textView.answer(i)ViewSingle.text = appRecord.answer(i);
        }
}
Run Code Online (Sandbox Code Playgroud)

objective-c

7
推荐指数
1
解决办法
2950
查看次数

基于int创建多个编号变量

如何NSDictionary使用数组计数创建多个变量?

这基本上就是我提出的,但我不确定如何使用Objective-C语法来完成这项工作.doesntContainAnother是一个NSArray.我希望字典的名称使用当前值loopInt.

int *loopInt = 0;
while (doesntContainAnother.count <= loopInt) {

    NSMutableDictionary *[NSString stringWithFormat:@"loopDictionary%i", loopInt] = [[[NSMutableDictionary alloc] init] autorelease];
    [NSString stringWithFormat:@"loopDictionary%i", loopInt] = [NSDictionary dictionaryWithObject:[array1 objectAtIndex:loopInt] 
                                                 forKey:[array2 objectAtIndex:loopInt]];
    loopInt = loopInt + 1;
}
Run Code Online (Sandbox Code Playgroud)

string variables objective-c variable-names

5
推荐指数
0
解决办法
1204
查看次数

标签 统计

objective-c ×2

string ×1

variable-names ×1

variables ×1