码迷,mamicode.com
首页 > 编程语言 > 详细

Swift ?和!

时间:2016-03-22 18:53:40      阅读:170      评论:0      收藏:0      [点我收藏+]

标签:

比如:

let window=UIApplication.sharedApplication().delegate?.window
window!!.rootViewController=TabBarController()

如果有delegate 就有window 没有delegate window就为nil   然后nil!! 不明白啊

如果变量为nil使用!强制解包会报错 window!!表示解包两次

上面的代码你可以这么理解

if let delegate = UIApplication.sharedApplication().delegate {
if let window = delegate.window {
window.rootViewController = TabBarController()
}
}

 

Swift ?和!

标签:

原文地址:http://www.cnblogs.com/huangzs/p/5307711.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!