gpt4 book ai didi

swift - MailComposeViewController 错误 : unexpectedly found nil

转载 作者:可可西里 更新时间:2023-11-01 02:15:24 24 4
gpt4 key购买 nike

我正在尝试将我发送的电子邮件的电子邮件地址和时间保存到表格 View 中。电子邮件发送正常,但每当我单击发送按钮时,我都会收到此错误(错误:在展开可选值时意外发现 nil)。我不确定我的代码中的错误在哪里。

发送按钮的代码:

//SentEmails Array
var sentEmails = [emailObject]()

//Default email
var sentEmailTo = "email@email.com"

//Dismiss Buttons for Mail Composer
func mailComposeController(controller:MFMailComposeViewController, didFinishWithResult result:MFMailComposeResult, error:NSError?) {

//Check for errors
if let error = error {
print("Error: \(error)")
return
}

switch result {
case MFMailComposeResultCancelled:
print("Mail Cancelled")
case MFMailComposeResultSaved:
print("Mail Saved")
case MFMailComposeResultSent:

//Save information to tableview
let emailSent = emailObject(sentTo: sentEmailTo, timeSent: NSDate())
sentEmails.append(emailSent)
tableView.reloadData()

print("Mail Sent")

case MFMailComposeResultFailed:
print("Mail sent failure: \(error)")
default:
break
}

controller.dismissViewControllerAnimated(true, completion: nil)
}

我的手 secret 码:

//Cell Configuration
func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell {

let cell = tableView.dequeueReusableCellWithIdentifier(cellIdentifier, forIndexPath: indexPath)

let row = indexPath.row

let dateFormat = NSDateFormatter()
dateFormat.dateStyle = .ShortStyle
dateFormat.timeStyle = .ShortStyle
cell.textLabel?.text = sentEmails[row].sentTo
cell.detailTextLabel?.text = dateFormat.stringFromDate(sentEmails[row].timeSent)



return cell
}

错误:

enter image description here

*不知道我能做到这一点哈哈,这是错误的详细信息:

enter image description here

最佳答案

当崩溃发生时,您可以按1行, enter image description here

它将显示有关崩溃发生位置的更多信息(在 ViewController 文件中)。你能张贴截图吗?

抱歉,我无法发布图片作为对该问题的评论。一旦我们知道更多,将编辑答案。

关于swift - MailComposeViewController 错误 : unexpectedly found nil,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39128629/

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