我对 Objective-c 很陌生,我正在创建一个保存记录的应用程序。当我单击保存按钮时,我尝试创建一种添加方法,尽管当您按下按钮时它不会保存数据,或者如果它不会显示它。数据显示在 tableView 中
这是保存按钮的代码:
-(void)savePatient:(id)sender {
LSAppDelegate *delegate = (LSAppDelegate *)[[UIApplication sharedApplication] delegate];
NSMutableArray *patients = delegate.patients;
UITextField *firstnameEntry = (UITextField *)[firstNameCell viewWithTag:777];
UITextField *surnameEntry = (UITextField *)[surnameNameCell viewWithTag:777];
UITextField *dobEntry = (UITextField *)[dobDateCell viewWithTag:777];
UITextField *homeNumberEntry = (UITextField *)[homeNumberCell viewWithTag:777];
UITextField *mobileNumberEntry = (UITextField *)[mobileNumberCell viewWithTag:777];
UITextField *emailAddressEntry = (UITextField *)[emailAddressCell viewWithTag:777];
UITextView *addressEntry = (UITextView *)[addressCell viewWithTag:777];
if (firstnameEntry.text.length > 0) {
Patient *newPatient = [[Patient alloc] init];
newPatient.patientName = firstnameEntry.text;
newPatient.patientSurname = surnameEntry.text;
newPatient.patientDoB = dobEntry.text;
newPatient.patientHomeNumber = homeNumberEntry.text;
newPatient.patientMobileNumber = mobileNumberEntry.text;
newPatient.patientEmail = emailAddressEntry.text;
newPatient.patientAddress = addressEntry.text;
newPatient.patientPicture = nil;
[patients addObject:newPatient];
LSViewController *viewController = delegate.viewController;
[viewController.tableView reloadData];
}
[delegate.navController popViewControllerAnimated:YES];
}
我发现问题出在这里
if (firstnameEntry.text.length > 0) {
请说如果你想要更多的代码
提前致谢