我真的很陌生,我真的需要帮助。我一直遇到这个问题。
类DetailViewController
没有初始值设定项
import UIKit
class DetailViewController: UIViewController {
@IBOutlet var namelabel : UILabel
@IBOutlet var phoneNumberLabel : UILabel
var contact : Contacts?
override func viewDidLoad() {
super.viewDidLoad()
if let contact = self.contact {
if let name = contact.name {
self.namelabel.text = name
}
if let phoneNumber = contact.phoneNumber {
self.phoneNumberLabel.text = phoneNumber
}
}
// Do any additional setup after loading the view.
}
override func didReceiveMemoryWarning() {
super.didReceiveMemoryWarning()
// Dispose of any resources that can be recreated.
}
答案 0 :(得分:0)
这将解决您的问题
@IBOutlet var namelabel : UILabel!
@IBOutlet var phoneNumberLabel : UILabel!
您需要为变量指定一个值(在构造函数中或在定义时)或将其标记为可选。