I made a contacts app for fun to dive into iOS.
Basically when you add a contact you can call email or text them.
Since i use the same viewcontroller when adding them and viewing them, how can i make it so that the buttons are disabled till the contact is viewed ie. coredata attributes not null?
For instance say I go to add a new contact, all the fields blank and i hit the email button, the app will crash since there is no entity to email cause the contact is not saved yet.
here is my working email code: I need it to not activate if the value for key email is null or empty to avoid a crash.
NSString *emaill = [contact valueForKey:@"email"];
MFMailComposeViewController *mailcontroller = [[MFMailComposeViewController alloc] init];
[mailcontroller setMailComposeDelegate:self];
NSString *email =[@""stringByAppendingString:emaill];
NSArray *emailArray = [[NSArray alloc] initWithObjects:email, nil];
[mailcontroller setToRecipients:emailArray];
[mailcontroller setSubject:@""];
[self presentViewController:mailcontroller animated:YES completion:nil];