gpt4 book ai didi

ios - 应用终止了从对象 [0] 插入 nil 对象的尝试

转载 作者:塔克拉玛干 更新时间:2023-11-02 20:10:16 25 4
gpt4 key购买 nike

这个过程正在发送电子邮件,它工作正常,但框架希望电子邮件的正文是一个 NSArray。所以我尝试将 NSString 转换为 NSDictionary 以包含在此处的 NSArray 中:

NSDictionary *plainPart = [NSDictionary dictionaryWithObjectsAndKeys:kSKPSMTPPartContentTypeKey,
message,kSKPSMTPPartMessageKey,kSKPSMTPPartContentTransferEncodingKey, nil];

然后我在这里实现:

smtpTestMessage.parts = [NSArray arrayWithObject:plainPart];

总的来说,这是我的代码:

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 = @"***";
smtpTestMessage.wantsSecure = YES;

smtpTestMessage.delegate = self;

NSDictionary *plainPart = [NSDictionary dictionaryWithObjectsAndKeys:kSKPSMTPPartContentTypeKey,
message,kSKPSMTPPartMessageKey,kSKPSMTPPartContentTransferEncodingKey, nil];


smtpTestMessage.parts = [NSArray arrayWithObject:plainPart];

[NSString stringWithFormat:@"%@",message];

[smtpTestMessage send];
NSLog(@"sent");

但遗憾的是,当我运行应用程序时,电子邮件到达最后阶段...然后应用程序终止说

2013-10-15 00:43:50.512 BullyBox[3662:60b] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '*** -[__NSPlaceholderArray initWithObjects:count:]: attempt to insert nil object from objects[0]'
*** First throw call stack:
(0x2f61ae8b 0x399156c7 0x2f5540cb 0x2f556749 0xc77f3 0x31dd555f 0x31dd54fb 0x31dd54cb 0x31dc10f3 0x31dd4f13 0x31dd4bdd 0x31dcfc09 0x31da4f59 0x31da3747 0x2f5e5f27 0x2f5e53ef 0x2f5e3bdf 0x2f54e541 0x2f54e323 0x342852eb 0x31e051e5 0xc91b5 0x39e0eab7)
libc++abi.dylib: terminating with uncaught exception of type NSException

编辑

现在我不断收到错误:

Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[__NSCFString appendString:]: nil argument'

非常感谢任何帮助!感谢您阅读本文! xD<3

最佳答案

确保 plainPart 已成功创建,而不是 nil。

关于ios - 应用终止了从对象 [0] 插入 nil 对象的尝试,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19373565/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com