我有這個問題,無論是「變種」我把自定義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