objective c - Obj C - Creating Unique Property List Keys using 'For' -
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 saving 9 string , corresponding numbers property list key. don't want write out every key @"slot value 1", @"slot value 2", etc.
so wondering how have 'for' statement insert 'x' integer after every title saved under key.
thank you.
use +stringwithformat:
:
[valuesavesdictionary setobject:slotvaluesave forkey:[nsstring stringwithformat:@"slot value %i", (x+1)]];
Comments
Post a Comment