So I have a MFMailComposeViewController that i call on when i click a button and i have an if statement that checks what a UILabel is equal to and if the device can send mail like this
if ([conditionlabel isEqual: @"Fair"] && [MFMailComposeViewController canSendMail]) {
NSString *emailBody = [NSString stringWithFormat:@"Product:%@ Make:%@ Year Manufactured:%@ Description:%@ Condition:Fair Email:%@",inputProduct,inputMake,inputYear,inputDescript, inputEmail];
NSArray *recipient = [NSArray arrayWithObject:@"LoveShackElectronics@gmail.com"];
MFMailComposeViewController *SuperLovedEmail = [[MFMailComposeViewController alloc]init];
[SuperLovedEmail setTitle:emailTitle];
[SuperLovedEmail setToRecipients:recipient];
[SuperLovedEmail setMessageBody:emailBody isHTML:NO];
[SuperLovedEmail setUserActivity:false];
[self presentViewController:SuperLovedEmail animated:YES completion:nil];
and i have an else statement after this that makes an alert and shows it. But for some reason, it always returns false and just shows the alert even on a device that i know is signed in through the mail app and is able to send mail.
You mean [conditionLabel.text isEqual:@"Fair"]
.
You are currently comparing the UILabel
to an NSString
. That will never be true. You need to compare the label's text
.
One thing that would have helped was if you used isEqualToString:
instead of isEqual:
.
Also, you really shouldn't be checking a label's value. A label is a view. Views are not meant to be a source of data. You should have actual data you check.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.