[HomeCell Class]
tableView.registerClass(HomeCell.self, forCellReuseIdentifier: "cellID")
选择器
NSNotificationCenter.defaultCenter().addObserver(self, selector: #selector(AppDelegate.changeRootViewController), name: "gotohome", object: nil)
问号(可选类型),感叹号(强制解包)
/**
Swift中类似于Int和Int?并不是同一种类型,不能进行相关运算,如果要运算只能解包;
可选类型其本质就是此类型内部存储分为“Some”和“None”两个部分,如果有值则存储到“Some”中,没有值则为“None”(早期Playground中可以看到两个部分,如今已经取消显示Some等描述了),使用感叹号强制解包的过程就是取出“Some”部分;
*/
var window: UIWindow?
var tabbarController:UITabBarController!
报警告(处理链接:http://www.tuicool.com/articles/2ARvEfr)
///Users/tanqihong/Desktop/swift学习/BanTangSwiftTest/BanTangSwiftTest/AppDelegate.swift:99:67: '++' is deprecated: it will be removed in Swift 3
///Users/tanqihong/Desktop/swift学习/BanTangSwiftTest/BanTangSwiftTest/AppDelegate.swift:99:9: C-style for statement is deprecated and will be removed in a future version of Swift
for var i = 0;i<tabbarController.viewControllers?.count ;i++ {
let nav = tabbarController.viewControllers![i] as! UINavigationController
nav.navigationBar.translucent = false
}
改为:
for nav in tabbarController.viewControllers as! [UINavigationController] {
nav.navigationBar.translucent = false
}
调用枚举
let leftItem = UIBarButtonItem.init(title: "返回", style: UIBarButtonItemStyle.Plain, target: self, action: #selector(self.leftItemPressed))