我刚刚将我的xcode从6.2更新到6.3.1。问题是我在项目中收到了很多错误信息。
/Users/MNurdin/Documents/iOS/xxxxx/Controllers/Profile/DirectoryTableViewController.swift:31:98: ' AnyObject&#39!;不能转换为' ViewController&#39 ;;你的意思是 使用' as!'迫使低垂?
我的一个代码受此错误消息影响。
let storyBoard : UIStoryboard = UIStoryboard(name: "Main", bundle:nil)
let viewController = storyBoard.instantiateViewControllerWithIdentifier("LoginView") as! ViewController
self.presentViewController(viewController, animated:true, completion:nil)
答案 0 :(得分:11)
更新到Xcode 6.3后,您现在正在使用Swift 1.2
在Swift 1.2之前,as
也用于强制转换。
Swift 1.2现在表示强制转换为as!
,以明确如果您尝试向下转换为实际上不代表值类型的类型,转换可能会失败。
因此,您必须使用as!
代替as