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, I'm trying to saving up to 9 string and corresponding numbers to a property list key. I don't want to write out every key @"Slot Value 1", @"Slot Value 2", etc.
您好,我正在尝试将最多9个字符串和相应的数字保存到属性列表键。我不想写出每个键@“Slot Value 1”,@“Slot Value 2”等。
So I was wondering how I could have the 'for' statement insert the 'x' integer after every title to be saved under that key.
所以我想知道如何在每个要保存在该键下的标题之后使用'for'语句插入'x'整数。
Thank you.
1 个解决方案
#1
1
Use +stringWithFormat:
:
[valueSavesDictionary setObject:slotValueSave forKey:[NSString stringWithFormat:@"Slot Value %i", (x+1)]];
#1
1
Use +stringWithFormat:
:
[valueSavesDictionary setObject:slotValueSave forKey:[NSString stringWithFormat:@"Slot Value %i", (x+1)]];