for (int x = 0; x < openSlots; x++) {
    NSNumber* slotValueSave = [[NSNumber alloc] initWithInt:[[slotValues objectAtIndex:x] intValue]];
    NSLog(@"Saving slot %@.", (x+1));
    [valueSavesDictionary setObject:slotValueSave forKey:@"Slot Value %i", (x+1)];
}
.

Hello,我正在尝试将最多9个字符串和相应的数字保存到属性列表密钥。我不想在每一个键@“插槽值1”,@“插槽值2”等。

所以我想知道我如何拥有'for'语句在每个键下保存的每个标题后插入'x'整数。

谢谢。

有帮助吗?

解决方案

使用+stringWithFormat:

[valueSavesDictionary setObject:slotValueSave forKey:[NSString stringWithFormat:@"Slot Value %i", (x+1)]];
.

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top