我是 iOS 编程新手,正在尝试找出如何中断程序流以等待响应。
基本上我想从我的应用程序发送一封电子邮件,并提供数据是什么,我想提示用户添加更多信息。
IE:
- (IBAction)sendEmail:(id)sender {
MyManagedObject *myObj = nil;
//Retrieve from the database.
NSManagedObjectContext *ctx = [self managedObjectContext];
NSFetchRequest *request = [[NSFetchRequest alloc] init];
NSEntityDescription *entity = [NSEntityDescription entityForName:@"MyManagedObject" inManagedObjectContext:ctx];
[request setEntity:entity];
NSError *error;
NSArray *array = [ctx executeFetchRequest:request error:&error];
NSUInteger count = [array count]; // May be 0 if the object has been deleted.
if (count > 0) {
myObj = (MyManagedObject *)[array objectAtIndex:0];
}
//Recipients
NSArray *toRecipents = [[NSArray alloc]init];
// Email Subject
NSString *emailTitle = [@"Report for Month of: " stringByAppendingString: dateString] ;
// Email Content
NSString *messageBody = @"";
if(myObj != nil) {
if (myObj.firstName) {
messageBody = [messageBody stringByAppendingString:[@"\nHello " stringByAppendingString: myObj.firstName]];
toRecipents = [NSArray arrayWithObject:myObj.emailAddress];
}
}
messageBody = [messageBody stringByAppendingString:@"\n\nBelow is my text...."];
messageBody = [messageBody stringByAppendingString:[@"\nMore Information...: " stringByAppendingString: myObj.moreInfo]];
NSString *addInfo = OPEN WINDOW FOR USER TO ADD INFO
if (addInfo != nil) {
messageBody = [messageBody stringByAppendingString:[@"\nAdditional Information...: " stringByAppendingString: addInfo]];
}
... send the email
}
我不确定这是否可能没有回调。基本上我想打断流程,放置一个覆盖并等待它在完成电子邮件之前关闭......