に名前のリストがありますUITableView。tableView のデリゲートは viewController です。ユーザーが別の名前を tableView に追加できるように、 (テキスト フィールドを使用して)IBActionを呼び出すために を使用します。UIAlertView
- (IBAction)addGuest:(UIButton *)sender
{   
    // open a alert with text field, cancel and add button
    UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"Add New Guest" message:@"Example: John Doe" delegate:self cancelButtonTitle:@"Cancel" otherButtonTitles:@"Add", nil];
    alert.alertViewStyle = UIAlertViewStylePlainTextInput;
    [alert show];
}
ユーザーが の [追加] ボタンをクリックするUIAlertViewと、テキスト フィールドの情報が plist に書き込まれます。
- (void)alertView:(UIAlertView *)alertView didDismissWithButtonIndex:(NSInteger)buttonIndex
{
    if (buttonIndex == 1) {
        NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
        NSString *documentsPath = [paths objectAtIndex:0];
        NSString *plistPath = [documentsPath stringByAppendingPathComponent:@"Guests.plist"];
        [self.guestList addObject:[[alertView textFieldAtIndex:0] text]];
        NSMutableDictionary *plistDict = [NSMutableDictionary dictionaryWithObjects:[NSArray arrayWithObjects:guestList, nil] forKeys:[NSArray arrayWithObjects:@"nameList", nil]];
        NSString *error = nil;
        NSData *plistData = [NSPropertyListSerialization dataFromPropertyList:plistDict format:NSPropertyListXMLFormat_v1_0 errorDescription:&error];
        if (plistData) {
            [plistData writeToFile:plistPath atomically:YES];
        } else {
            NSLog(@"Error in saveData: %@", error);
        }
    }
}
この時点で、(上記のメソッド内で) tableView をリロードして、新しく追加された名前が表示されるようにします。UIAlertViewのデリゲートを自分自身に設定しました。
ただし、[self.tableView reloadData]このメソッドでは tableView が認識されないため機能しません。さまざまなバリエーションを試しましたが、何も機能しません。
これを行うにはどうすればよいですか?
ありがとうございました!