-2
-(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“消息”放入 NSArray 以用于 smtpTestMessage.parts?解决此问题后,应用程序应该可以工作。

老实说,如果我可以把任何东西放在 smtpTestMessage.parts 中,它应该可以工作。只要它不回来为零。

4

1 回答 1

5

在调试器中创建异常断点 ( https://developer.apple.com/library/ios/recipes/xcode_help-breakpoint_navigator/articles/adding_an_exception_breakpoint.html )。打破它,然后发布回溯。

这是任何人都可以根据所提供的证据给出的答案。

于 2013-10-15T22:47:23.553 回答