我有这个问题,无论是“变种”我把自定义uitabelviewcell什么变量,则返回nil 而IBOulets作品就好定制uitabelviewcell变量返回nil,IBOutlets工作正常 - Mailcore2
tableviewcell.swift
import Foundation
import UIKit
class tableViewCell: UITableViewCell {
@IBOutlet weak var tableViewLabelDate: UILabel!
@IBOutlet weak var tableViewLabelDisplayName: UILabel!
@IBOutlet weak var tableViewLabelSubject: UILabel!
@IBOutlet weak var tableViewTextViewInfo: UITextView!
var messageRenderingOperation: MCOIMAPMessageRenderingOperation!
required init(coder aDecoder: NSCoder) {
super.init(coder: aDecoder)
}
tableview.swift
override func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell {
var cell2: tableViewCell = tableView.dequeueReusableCellWithIdentifier(reuseTableViewCellIdentifier, forIndexPath: indexPath) as tableViewCell
cell2.tag = 0
let message: MCOIMAPMessage = mailbox?.messages[indexPath.row] as MCOIMAPMessage!
let uidKey = message.uid
cell2.tableViewLabelDisplayName?.text = mailbox?.messages[indexPath.row].header.from.displayName
cell2.tableViewLabelSubject?.text = mailbox?.messages[indexPath.row].header.subject
println("Got the subject line: \(mailbox?.messages[indexPath.row].header.subject)")
cell2.messageRenderingOperation = self.imapSession.plainTextBodyRenderingOperationWithMessage(message, folder: "INBOX", stripWhitespace: false)
cell2.messageRenderingOperation?.start({ (plaintext: String!, error: NSError!) -> Void in // Crash at this line
if error != nil{
println("ERROR at messageRenderingOperation\(error)")
}else {
cell2.tableViewTextViewInfo.text = plaintext
cell2.messageRenderingOperation = nil
}
})
return cell2
}
它在该行崩溃
cell2.messageRenderingOperation?.start({ (plaintext: String!, error: NSError!) -> Void in // Crash at this line
UPDATE
我已经试过这藏汉
class tableviewController: UITableViewController, UITableViewDataSource, UITableViewDelegate {
var messageRenderingOperation: MCOIMAPMessageRenderingOperation?
override func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell {
self.messageRenderingOperation = imapSession.plainTextBodyRenderingOperationWithMessage(message, folder: "INBOX")
self.messageRenderingOperation.start({ (plaintext: String!, error: NSError!) -> Void in
if error != nil{
println("ERROR at messageRenderingOperation\(error)")
}else {
cell2.tableViewTextViewInfo.text = plaintext
cell2.messageRenderingOperation = nil
}
})
}
}
更新2
现在如果我使用
var messageRenderingOperation = MCOIMAPMessageRenderingOperation()
那么它不是零,但仍然崩溃。我认为这是“插件”的问题?
你有没有尝试与Obj-C代码? –
我尽我所能从mailcore2应用程序中的示例复制代码,相同的结果...我不知道为什么它不会工作 – KennyVB