在下面的代码中,我有一个NSNumbers字典转换为数组。然后随机排序,前四行需要显示在适当的标签中。 NSLog确实显示数组显示适当的数字。我相信代码失败,因为我需要将NSNumbers转换为NSStrings。什么是适用的代码或我忽略了什么?将NSNumbers转换为NSStrings
-(IBAction)shakeit {
NSDictionary * myExampleDict = [[NSUserDefaults standardUserDefaults] dictionaryForKey:@"dictionaryKey"];
exampleArray = [myExampleDict allValues];
NSUInteger count = [exampleArray count];
for (NSUInteger i = 0; i < count; ++i) {
int nElements = count - i;
int n = (arc4random() % nElements) + i;
[exampleArray exchangeObjectAtIndex:i withObjectAtIndex:n];
}
NSString *one = [exampleArray objectAtIndex:1];
NSString *two = [exampleArray objectAtIndex:2];
NSString *three = [exampleArray objectAtIndex:3];
NSString *four = [exampleArray objectAtIndex:4];
select1.text = one;
select2.text = two;
select3.text = three;
select4.text = four;
}
可能重复其他视图](http://stackoverflow.com/questions/3969972/convert-nsnumber-to-nsstring-and-use-it-in-other-view) – DarthJDG 2011-06-10 08:20:11