在下面的代碼中,我有一個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