2017-05-31 94 views
-2

我开始学习Swift 3,但我不断收到错误。“使用未解析的标识符”

例:

使用未解决的识别符 'UIAlertController'

使用未解决的识别符 'UIAlert'

我的代码

@IBAction func click(_ sender: Any) { 
    let alert = UIAlertController(title: "Alert", message: "Message", preferredStyle: UIAlertControllerStyle.alert) 
    alert.addAction(UIAlertAction(title: "Click", style: UIAlertActionStyle.default, handler: nil)) 
    self.present(alert, animated: true, completion: nil) 
} 
+0

“导入UIKit”? (等等......你的问题上有OSX标签,你是在为Mac或iOS编写代码吗?) –

+0

没有这样的模块'UIKit' http://prntscr.com/fedb0q –

+0

如果你正在创建一个Mac项目, “UI”-stuff不存在。 –

回答

1

申请OS X/macOS使用自己的SDK的,这是不一样的iOS

例如,UIKitiOSAppKitmacOS等价,但它们是不可互换 - 这意味着使用库,框架,SDK的,等了正确的平台。

+0

非常感谢您提供给我的信息。 –