I am pretty new to objective-c and I am creating an app where records are held. I have tried to make an adding method when I click a save button though it doesn't save the data when you press the button or if it does it doesn't display it. The data is being shown in a tableView
here is the code for the save button:
-(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];
}
I've found that the issue is here
if (firstnameEntry.text.length > 0) {
please say if you want any more code
Thanks in advance
firstNameTextEntry.textis and see if it actually enters your if statement