-(IBAction)send:(id)sender
{
NSString *message = [NSString stringWithFormat:@"\r\rThis is a report from the Arabian Bully Box iOS mobile application:\r\rName of victim = %@ \rName of Bully = %@ \rLocation = %@ \rDate(s) of Incident = %@ \rWitnesses = %@ \rDescription = %@", nameVictom.text, nameBully.text, location.text, date.text, witness.text, description.text];
// label.text = message;
NSLog(@"%@", message);
nameVictom.text = @"";
nameBully.text = @"";
location.text = @"";
date.text = @"";
witness.text = @"";
description.text = @"";
label.text = @"Thank you for your help.";
label.textColor = [UIColor blackColor];
label.shadowColor = [UIColor clearColor];
send.enabled = NO;
NSLog(@"Start eMail");
SKPSMTPMessage *smtpTestMessage = [[SKPSMTPMessage alloc] init];
smtpTestMessage.fromEmail = @"***@gmail.com";
smtpTestMessage.toEmail = @"***@yahoo.com";
smtpTestMessage.relayHost = @"smtp.gmail.com";
smtpTestMessage.requiresAuth = YES;
smtpTestMessage.login = @"***@gmail.com";
smtpTestMessage.pass = @"***";
smtpTestMessage.subject = @"Bully Box Submission";
smtpTestMessage.wantsSecure = YES;
smtpTestMessage.delegate = self;
NSDictionary *plainPart = [NSDictionary dictionaryWithObjectsAndKeys:kSKPSMTPPartContentTypeKey,
message,kSKPSMTPPartMessageKey,kSKPSMTPPartContentTransferEncodingKey, nil];
// NSDictionary *plainPart = @{
// message: kSKPSMTPPartContentTypeKey,
// kSKPSMTPPartContentTransferEncodingKey: kSKPSMTPPartMessageKey
// };
smtpTestMessage.parts = [NSArray arrayWithObject:plainPart];
[NSString stringWithFormat:@"%@",message];
NSLog(@"\r\r\rAbout to send\r\r\r");
[smtpTestMessage send];
NSLog(@"sent");
}
每当我运行它时,我按下“发送”按钮,电子邮件几乎发送,直到我遇到这个:
Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '- [__NSCFString appendString:]: nil argument'
我觉得好像我已经尝试过一切。我为这么直率而道歉,但我已经被这一段时间困扰了!老实说我准备放弃了。预先感谢您的任何帮助!谢谢你甚至看这篇文章! xD <3
修改
好。所以smtpTestMessage.parts回来没了。它被设置为NSArray。如何将NSString“消息”放入smtpTestMessage.parts的NSArray中?一旦解决了这个问题,应用程序应该可行。
老实说,如果我可以将任何东西放在smtpTestMessage.parts中,它应该可以工作。只要它没有回来为零。
答案 0 :(得分:5)
在调试器中创建一个异常断点(https://developer.apple.com/library/ios/recipes/xcode_help-breakpoint_navigator/articles/adding_an_exception_breakpoint.html)。打破它,然后发布回溯。
这是任何人都可以根据所提供的证据给出的答案。