简体   繁体   English

Swift tableview numberOfRowsInSection返回nil致命错误可选值

[英]Swift tableview numberOfRowsInSection return nil fatal error Optional value

Hello i have tableview and loading items when table numberOFRowsInSection 0 gives fatal error: unexpectedly found nil while unwrapping an Optional value 您好,当表编号OFRowsInSection 0出现致命错误时,我有tableview并正在加载项目:展开一个Optional值时意外地找到nil

My code here 我的代码在这里

var itemsList = [String]()


internal func tableView(tableView: UITableView, numberOfRowsInSection section: Int) -> Int
{
      self.itemsmessage.text = "Listed your last \(itemsList.count) items"

    return itemsList.count
}

Giving Error 产生错误

fatal error: unexpectedly found nil while unwrapping an Optional value 致命错误:解开Optional值时意外发现nil

When return nil gives this error in self.itemsmessage.text line. 当返回nil时,在self.itemsmessage.text行中给出此错误。 Thank you. 谢谢。

Your self.itemsmessage may not be connected to the actual control in your view controller. 您的self.itemsmessage可能未连接到视图控制器中的实际控件。 Check that its connected. 检查其是否连接。 To put safe code around that try this. 要解决此问题,请尝试使用安全的代码。

if let message = self.itemsmessage { message.text = "Listed your last \\(itemsList.count) items" } else { print("Seems like your itemsmessage is not connected to a text label") }

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 致命错误:选择tableView单元格时,在展开可选值swift时意外发现nil - fatal error: unexpectedly found nil while unwrapping an Optional value swift When Selecting tableView Cells 快速搜索栏和表格视图-致命错误:在展开可选值时意外发现nil - swift searchbar and tableview - fatal error: unexpectedly found nil while unwrapping an optional value 致命错误:在Tableview中展开Optional值时意外发现nil - fatal error: unexpectedly found nil while unwrapping an Optional value in Tableview Swift:致命错误:在展开可选值时意外发现nil - Swift : fatal error: unexpectedly found nil while unwrapping an Optional value 快速致命错误:解开Optional值时意外发现nil - swift fatal error: unexpectedly found nil while unwrapping an Optional value Swift致命错误:解开Optional值时意外发现nil - Swift fatal error: unexpectedly found nil while unwrapping an Optional value 致命错误:在Swift 3中解开Optional值时意外发现nil - fatal error: unexpectedly found nil while unwrapping an Optional value in Swift 3 SWIFT-致命错误:解开可选值时意外发现nil - SWIFT - fatal error: unexpectedly found nil while unwrapping an Optional value Swift中的可选类型错误:致命错误:解开可选值时意外发现nil - Optional type error in Swift: fatal error: unexpectedly found nil while unwrapping an Optional value Xcode Swift:appDelgate.window! is nil :致命错误:在解开可选值时意外发现 nil - Xcode Swift : appDelgate.window! is nil : Fatal error: Unexpectedly found nil while unwrapping an Optional value
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM