0
所以我想在NSMutableArray中打印用戶。但是這些弦一直沒有出現。從NSMutableArray打印
這裏是我有:
int users = 0;
- (IBAction)addNewUser:(id)sender {
NSString *string;
string = userNameTextField.text;
[usernameArray insertObject:string atIndex:users];
users++;
[self showUsers];
}
-(void)showUsers{
for (int i = 0; i < users; i++){
NSString *s = textView.text;
NSString *add;
add = [NSString stringWithFormat:@"%@ ",[usernameArray objectAtIndex:i]];
NSString *display = [NSString stringWithFormat:@"%@ \n %@", s, add];
textView.text = display;
}
}
我也曾嘗試
-(void)showUsers{
for (int i = 1; i < users; i++){
NSString *s = textView.text;
NSString *add;
add = [usernameArray objectAtIndex:i];
NSString *display = [NSString stringWithFormat:@"%@ \n %@", s, add];
textView.text = display;
}
}
你確認'textView'和'usernameArray'不是'nil'嗎? – rmaddy
如何查看usernameArray是否爲零? – nfoggia
使用調試器並添加一個'NSLog'語句。 – rmaddy