我正在开发联系人应用程序。我要添加联系人,打开这样一个新的观点:将数据传递到根控制器
RootViewController.m ... 它有一个NSMutableArray的所谓接触
- (IBAction)addContact:(id)sender {
AddContViewController *cont = [[AddContViewController alloc]init];
[self.navigationController presentViewController:cont animated:YES completion:nil];
}
,然后再回来,并添加联系人根视图控制器的阵列:
AddContViewController.m
- (IBAction)acceptAction:(id)sender {
if ([[firstName text] length] < 1 && [[lastName text] length] < 1)
{
UIAlertView *alert = [[UIAlertView alloc]initWithTitle:@"Oh no!" message:@"Invalid contact information!" delegate:self cancelButtonTitle:@"Ok" otherButtonTitles: nil];
[alert show];
}
else{
//创建接触,并把它的根视图控制器的阵列中
Contact *cont = [[Contact alloc]initWithFirstName:[firstName text] lastName:[lastName text] andDOB:[dobPicker date]];
//现在我不知道该怎么办....
[self dismissViewControllerAnimated:YES completion:^{
UIAlertView *alert = [[UIAlertView alloc]initWithTitle:@"Success!" message:@"Contact added successfully!" delegate:self cancelButtonTitle:@"Ok" otherButtonTitles: nil];
[alert show];
}];
}
}