0

所以我对这门课有一个严重的问题......

目前,当用户实际发送电子邮件时,ActivityIndi​​cator 显示...太棒了!!!以及 UI 没有被冻结......那太酷了!

问题是,如果用户推送到另一个实际上关闭发送电子邮件视图控制器的视图控制器,应用程序崩溃......我注意到我必须等到第二个“ *** stopping watchdog ***”字符串被记录......以及这个“ S: 221 2.0.0 closing connection i16sm31117760pag.18 - gsmtp

这是完整的日志,

013-07-09 09:50:50.655 PowerOneApp[29380:c07] C: Attempting to connect to server at: smtp.gmail.com:25
2013-07-09 09:50:50.752 PowerOneApp[29380:c07] *** stopping watchdog ***
2013-07-09 09:50:50.752 PowerOneApp[29380:c07] S: 220 mx.google.com ESMTP nr8sm18121079pbc.6 - gsmtp
2013-07-09 09:50:50.752 PowerOneApp[29380:c07] C: EHLO localhost
2013-07-09 09:50:50.752 PowerOneApp[29380:c07] *** starting short watchdog ***
2013-07-09 09:50:50.788 PowerOneApp[29380:c07] *** stopping watchdog ***
2013-07-09 09:50:50.788 PowerOneApp[29380:c07] S: 250-mx.google.com at your service, [70.89.67.1]
2013-07-09 09:50:50.788 PowerOneApp[29380:c07] *** stopping watchdog ***
2013-07-09 09:50:50.788 PowerOneApp[29380:c07] S: 250-SIZE 35882577
2013-07-09 09:50:50.788 PowerOneApp[29380:c07] *** stopping watchdog ***
2013-07-09 09:50:50.789 PowerOneApp[29380:c07] S: 250-8BITMIME
2013-07-09 09:50:50.789 PowerOneApp[29380:c07] *** stopping watchdog ***
2013-07-09 09:50:50.789 PowerOneApp[29380:c07] S: 250-STARTTLS
2013-07-09 09:50:50.789 PowerOneApp[29380:c07] C: STARTTLS
2013-07-09 09:50:50.790 PowerOneApp[29380:c07] *** starting short watchdog ***
2013-07-09 09:50:50.790 PowerOneApp[29380:c07] *** stopping watchdog ***
2013-07-09 09:50:50.790 PowerOneApp[29380:c07] S: 250 ENHANCEDSTATUSCODES
2013-07-09 09:50:50.832 PowerOneApp[29380:c07] *** stopping watchdog ***
2013-07-09 09:50:50.832 PowerOneApp[29380:c07] S: 220 2.0.0 Ready to start TLS
2013-07-09 09:50:50.832 PowerOneApp[29380:c07] Beginning TLSv1...
2013-07-09 09:50:50.832 PowerOneApp[29380:c07] C: EHLO localhost
2013-07-09 09:50:51.102 PowerOneApp[29380:c07] *** starting short watchdog ***
2013-07-09 09:50:51.140 PowerOneApp[29380:c07] *** stopping watchdog ***
2013-07-09 09:50:51.140 PowerOneApp[29380:c07] S: 250-mx.google.com at your service, [70.89.67.1]
2013-07-09 09:50:51.140 PowerOneApp[29380:c07] *** stopping watchdog ***
2013-07-09 09:50:51.140 PowerOneApp[29380:c07] S: 250-SIZE 35882577
2013-07-09 09:50:51.141 PowerOneApp[29380:c07] *** stopping watchdog ***
2013-07-09 09:50:51.141 PowerOneApp[29380:c07] S: 250-8BITMIME
2013-07-09 09:50:51.141 PowerOneApp[29380:c07] *** stopping watchdog ***
2013-07-09 09:50:51.141 PowerOneApp[29380:c07] S: 250-AUTH LOGIN PLAIN XOAUTH XOAUTH2
2013-07-09 09:50:51.141 PowerOneApp[29380:c07] *** stopping watchdog ***
2013-07-09 09:50:51.142 PowerOneApp[29380:c07] S: 250 ENHANCEDSTATUSCODES
2013-07-09 09:50:51.142 PowerOneApp[29380:c07] C: AUTH PLAIN AGpzZXR0aW5nMzIARm9vdGJhbGwzMyE=
2013-07-09 09:50:51.142 PowerOneApp[29380:c07] *** starting short watchdog ***
2013-07-09 09:50:51.983 PowerOneApp[29380:c07] *** stopping watchdog ***
2013-07-09 09:50:51.983 PowerOneApp[29380:c07] S: 235 2.7.0 Accepted
2013-07-09 09:50:51.983 PowerOneApp[29380:c07] C: MAIL FROM:<jsetting32@icloud.com> BODY=8BITMIME
2013-07-09 09:50:51.983 PowerOneApp[29380:c07] *** starting short watchdog ***
2013-07-09 09:50:52.025 PowerOneApp[29380:c07] *** stopping watchdog ***
2013-07-09 09:50:52.025 PowerOneApp[29380:c07] S: 250 2.1.0 OK nr8sm18121079pbc.6 - gsmtp
2013-07-09 09:50:52.025 PowerOneApp[29380:c07] C: RCPT TO:<jsetting32@gmail.com>
2013-07-09 09:50:52.025 PowerOneApp[29380:c07] *** starting short watchdog ***
2013-07-09 09:50:52.069 PowerOneApp[29380:c07] *** stopping watchdog ***
2013-07-09 09:50:52.069 PowerOneApp[29380:c07] S: 250 2.1.5 OK nr8sm18121079pbc.6 - gsmtp
2013-07-09 09:50:52.069 PowerOneApp[29380:c07] C: DATA
2013-07-09 09:50:52.069 PowerOneApp[29380:c07] *** starting short watchdog ***
2013-07-09 09:50:53.220 PowerOneApp[29380:c07] *** stopping watchdog ***
2013-07-09 09:50:53.220 PowerOneApp[29380:c07] S: 354  Go ahead nr8sm18121079pbc.6 - gsmtp
2013-07-09 09:50:53.221 PowerOneApp[29380:c07] *** starting long watchdog ***
2013-07-09 09:50:54.700 PowerOneApp[29380:c07] *** stopping watchdog ***
2013-07-09 09:50:54.700 PowerOneApp[29380:c07] S: 250 2.0.0 OK 1373388654 nr8sm18121079pbc.6 - gsmtp
2013-07-09 09:50:54.700 PowerOneApp[29380:c07] C: QUIT
2013-07-09 09:50:54.701 PowerOneApp[29380:c07] *** starting short watchdog ***
2013-07-09 09:50:54.734 PowerOneApp[29380:c07] *** stopping watchdog ***
2013-07-09 09:50:54.734 PowerOneApp[29380:c07] S: 221 2.0.0 closing connection nr8sm18121079pbc.6 - gsmtp
2013-07-09 09:50:58.656 PowerOneApp[29380:c07] *** stopping watchdog ***
2013-07-09 09:51:11.190 PowerOneApp[29380:c07] C: Attempting to connect to server at: smtp.gmail.com:25
2013-07-09 09:51:11.276 PowerOneApp[29380:c07] *** stopping watchdog ***
2013-07-09 09:51:11.276 PowerOneApp[29380:c07] S: 220 mx.google.com ESMTP i16sm31117760pag.18 - gsmtp
2013-07-09 09:51:11.276 PowerOneApp[29380:c07] C: EHLO localhost
2013-07-09 09:51:11.277 PowerOneApp[29380:c07] *** starting short watchdog ***
2013-07-09 09:51:11.317 PowerOneApp[29380:c07] *** stopping watchdog ***
2013-07-09 09:51:11.318 PowerOneApp[29380:c07] S: 250-mx.google.com at your service, [70.89.67.1]
2013-07-09 09:51:11.318 PowerOneApp[29380:c07] *** stopping watchdog ***
2013-07-09 09:51:11.318 PowerOneApp[29380:c07] S: 250-SIZE 35882577
2013-07-09 09:51:11.318 PowerOneApp[29380:c07] *** stopping watchdog ***
2013-07-09 09:51:11.318 PowerOneApp[29380:c07] S: 250-8BITMIME
2013-07-09 09:51:11.319 PowerOneApp[29380:c07] *** stopping watchdog ***
2013-07-09 09:51:11.319 PowerOneApp[29380:c07] S: 250-STARTTLS
2013-07-09 09:51:11.319 PowerOneApp[29380:c07] C: STARTTLS
2013-07-09 09:51:11.319 PowerOneApp[29380:c07] *** starting short watchdog ***
2013-07-09 09:51:11.320 PowerOneApp[29380:c07] *** stopping watchdog ***
2013-07-09 09:51:11.320 PowerOneApp[29380:c07] S: 250 ENHANCEDSTATUSCODES
2013-07-09 09:51:11.354 PowerOneApp[29380:c07] *** stopping watchdog ***
2013-07-09 09:51:11.354 PowerOneApp[29380:c07] S: 220 2.0.0 Ready to start TLS
2013-07-09 09:51:11.355 PowerOneApp[29380:c07] Beginning TLSv1...
2013-07-09 09:51:11.355 PowerOneApp[29380:c07] C: EHLO localhost
2013-07-09 09:51:11.644 PowerOneApp[29380:c07] *** starting short watchdog ***
2013-07-09 09:51:11.680 PowerOneApp[29380:c07] *** stopping watchdog ***
2013-07-09 09:51:11.680 PowerOneApp[29380:c07] S: 250-mx.google.com at your service, [70.89.67.1]
2013-07-09 09:51:11.680 PowerOneApp[29380:c07] *** stopping watchdog ***
2013-07-09 09:51:11.680 PowerOneApp[29380:c07] S: 250-SIZE 35882577
2013-07-09 09:51:11.680 PowerOneApp[29380:c07] *** stopping watchdog ***
2013-07-09 09:51:11.681 PowerOneApp[29380:c07] S: 250-8BITMIME
2013-07-09 09:51:11.681 PowerOneApp[29380:c07] *** stopping watchdog ***
2013-07-09 09:51:11.681 PowerOneApp[29380:c07] S: 250-AUTH LOGIN PLAIN XOAUTH XOAUTH2
2013-07-09 09:51:11.681 PowerOneApp[29380:c07] *** stopping watchdog ***
2013-07-09 09:51:11.682 PowerOneApp[29380:c07] S: 250 ENHANCEDSTATUSCODES
2013-07-09 09:51:11.682 PowerOneApp[29380:c07] C: AUTH PLAIN AGpzZXR0aW5nMzIARm9vdGJhbGwzMyE=
2013-07-09 09:51:11.682 PowerOneApp[29380:c07] *** starting short watchdog ***
2013-07-09 09:51:12.462 PowerOneApp[29380:c07] *** stopping watchdog ***
2013-07-09 09:51:12.463 PowerOneApp[29380:c07] S: 235 2.7.0 Accepted
2013-07-09 09:51:12.463 PowerOneApp[29380:c07] C: MAIL FROM:<jsetting32@icloud.com> BODY=8BITMIME
2013-07-09 09:51:12.463 PowerOneApp[29380:c07] *** starting short watchdog ***
2013-07-09 09:51:12.502 PowerOneApp[29380:c07] *** stopping watchdog ***
2013-07-09 09:51:12.503 PowerOneApp[29380:c07] S: 250 2.1.0 OK i16sm31117760pag.18 - gsmtp
2013-07-09 09:51:12.503 PowerOneApp[29380:c07] C: RCPT TO:<jsetting32@gmail.com>
2013-07-09 09:51:12.503 PowerOneApp[29380:c07] *** starting short watchdog ***
2013-07-09 09:51:12.544 PowerOneApp[29380:c07] *** stopping watchdog ***
2013-07-09 09:51:12.544 PowerOneApp[29380:c07] S: 250 2.1.5 OK i16sm31117760pag.18 - gsmtp
2013-07-09 09:51:12.544 PowerOneApp[29380:c07] C: DATA
2013-07-09 09:51:12.544 PowerOneApp[29380:c07] *** starting short watchdog ***
2013-07-09 09:51:13.102 PowerOneApp[29380:c07] Let us know about a broken feature
2013-07-09 09:51:13.289 PowerOneApp[29380:c07] *** stopping watchdog ***
2013-07-09 09:51:13.289 PowerOneApp[29380:c07] S: 354  Go ahead i16sm31117760pag.18 - gsmtp
2013-07-09 09:51:13.290 PowerOneApp[29380:c07] *** starting long watchdog ***
2013-07-09 09:51:14.751 PowerOneApp[29380:c07] *** stopping watchdog ***
2013-07-09 09:51:14.751 PowerOneApp[29380:c07] S: 250 2.0.0 OK 1373388674 i16sm31117760pag.18 - gsmtp
2013-07-09 09:51:14.751 PowerOneApp[29380:c07] C: QUIT
2013-07-09 09:51:14.751 PowerOneApp[29380:c07] *** starting short watchdog ***
2013-07-09 09:51:14.792 PowerOneApp[29380:c07] *** stopping watchdog ***
2013-07-09 09:51:14.793 PowerOneApp[29380:c07] S: 221 2.0.0 closing connection i16sm31117760pag.18 - gsmtp

现在,我“非常快”退出发送电子邮件的视图并继续发送电子邮件,然后我收到此消息*** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[__NSCFType messageSent:]: unrecognized selector sent to instance 0xa0a8e50'

当我使用时会发生这种情况[testMsg performSelectorOnBackgroundThread:@selector(send) withObject:nil];

但是当我使用时,[testMsg performSelectorOnMainThread:@selector(send) withObject:nil waitUntilDone:YES];我遇到了与首先发布的日志语句相同的问题......

对不起我可怕的措辞,但我对这个错误有点沮丧:(。

4

1 回答 1

1

我猜这个错误不在于通过 SMTP 发送邮件。似乎委托对象在 messageSent: 委托方法被调用之前已被释放。

我的建议是在 Application Delegate 中执行 SKPSMTPMessage 发送操作。如果您不希望 SMTP 消息发送句柄位于应用程序委托中,请保留您的委托对象,直到发送邮件或将 SKSMTPMessage 的委托设置为 nil,此时委托对象正在被释放。

希望能帮助到你

于 2013-10-01T10:51:11.760 回答