0
为什么属性未使用默认值进行初始化?如果我取消注释Swift - 未设置默认属性值
// required init?(coder aDecoder: NSCoder)
// {
// super.init(coder: aDecoder)
// }
一切工作正常。
UPDATE:
看起来与普通型 “元” 的问题,下面的代码按预期工作:
import UIKit
class ANTableViewController: UIViewController, UITableViewDataSource, UITableViewDelegate
{
@IBOutlet weak var tableView: UITableView!
var sections: [[SPMenuItem]] = [[SPMenuItem]]()
var a = "qwe"
var configureCellBlock : ((UITableView, NSIndexPath, SPMenuItem) -> UITableViewCell)!
var didSelectElementBlock : ((SPMenuItem) -> Void) = { (element) -> Void in }
func elementForIndexPath(indexPath: NSIndexPath) -> SPMenuItem
{
let elements = sections[indexPath.section]
let element = elements[indexPath.row]
return element
}
// required init?(coder aDecoder: NSCoder)
// {
// super.init(coder: aDecoder)
// }
// MARK: - UITableViewDataSource
func numberOfSectionsInTableView(tableView: UITableView) -> Int { return sections.count }
func tableView(tableView: UITableView, numberOfRowsInSection section: Int) -> Int { return sections[section].count }
func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell
{
let element = elementForIndexPath(indexPath)
assert(configureCellBlock != nil, "configureCellBlock should not be nil!")
let cell = configureCellBlock(tableView, indexPath, element)
return cell
}
}
而不是粘贴的图片,如果你发布的代码,你会更好地吸引观众和更快的解决方案。另外,请详细说明您面临的问题和问题。 – Abhinav
如果您怀疑调试器的变量窗格显示了什么,然后打印值(通过调试控制台中的命令或右键单击该值并选择打印)。有时候这些值是不同的。当达到这种情况时,印刷他们说实话。只是不要问我为什么。 –
如果您从您的代码中删除debugPrint(部分),它可以工作吗? – user3441734