我有我UIViewController子類可選鏈接無法正常運行
class SideMenu: UIViewController {
var contentViewController: UIViewController?
override func shouldAutorotate() -> Bool {
return contentViewController?.shouldAutorotate()
}
}
但由於某些原因,我得到以下錯誤以下代碼:
Value of optional type 'Bool?' not unwrapped; did you mean to use '!' or '??'
我期望可選擇的鏈接打開可選,但這不可能是真的?我錯了嗎?
的功能將在contentViewController爲零的情況下返回nil,或者使返回類型爲Bool?或者使用if構造來進行測試,在contentVC = nil情況下返回false – 2014-10-08 16:58:48