我正在更新一些example code到最新版本的Swift(从beta 4到1.2)以及最新版本的Couchbase Lite。
我遇到的问题是UITextField总是为零。我检查了它在IB / xib文件中的连接。我已断开连接并将其重新连接到UITextField
对象addItemTextField
。
宣布为
@IBOutlet weak var addItemTextField: UITextField!
及相关功能:
func configureView() {
// Update the user interface for the detail item.
if let detail: AnyObject = self.detailItem {
if let label = self.detailDescriptionLabel {
label.text = detail.description
}
title = detail.title
assert(addItemTextField != nil, "addItemTextField cannot be nil") // <- always hits this assertion
addItemTextField.enabled = true
addImageButton.enabled = true
navigationItem.rightBarButtonItem!.title = "Share"
assert(dataSource != nil, "detail.dataSource not connected")
dataSource!.labelProperty = "title"
dataSource!.query = detail.queryTasks().asLiveQuery()
} else {
title = nil
addImageButton.enabled = false
addItemTextField.enabled = false
}
}
override func viewDidLoad() {
app = UIApplication.sharedApplication().delegate as? AppDelegate
super.viewDidLoad()
// Do any additional setup after loading the view, typically from a nib.
self.configureView()
}
ViewController的一部分用
实例化performSegueWithIdentifier("showDetail", sender: self)
(当然我已检查过标识符是否在xib文件中正确设置)
我可能错过了什么吗?