2011-04-19 34 views
0

我想使用NSMutableArray,然後使用它的內容。我的代碼如下:把東西放進NSMutableArray並使用它

[_sizedWordList addObject:[_wordList objectAtIndex:i]]; 


UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"Alert" message:[_sizedWordList objectAtIndex:0] delegate:nil cancelButtonTitle:@"Cancel" otherButtonTitles: nil]; 
    [alert show]; 
    [alert release]; 

凡_sizedWordList是NSMutableArray和_wordList是NSArray。出於某種原因,警報未顯示。

+1

它顯示如果你把一些靜態字符串,而不是你的數組的內容? – 2011-04-19 07:26:05

+0

@Nick號即使我說'[_sizedWordList addObject:@「hello」];'並試圖顯示那麼它不起作用。 – locoboy 2011-04-19 07:34:25

+0

你可以嘗試像這樣:[[[UIAlertView alloc] initWithTitle:@「Alert」message:@「A message」delegate:nil cancelButtonTitle:@「Cancel」otherButtonTitles:nil];'? – 2011-04-19 07:37:12

回答

1

好吧,那麼你的數組肯定有問題。看,我已經創建了這個小實例。

NSMutableArray *myArray = [NSMutableArray array]; 

[myArray addObject:@"Hello everybody"]; 

UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"Alert" 
               message:[myArray objectAtIndex:0] 
               delegate:nil 
             cancelButtonTitle:@"Cancel" 
             otherButtonTitles:nil]; 
[alert show]; 
[alert release]; 
相關問題