【发布时间】:2015-08-31 13:24:40
【问题描述】:
我有一个 swift 项目,我想在其中检索设备名称并显示在 UITableViewCell 中。
但是当我想打电话给UIDevice.currentDevice()时
override func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell
编译器失败:
命令 /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/swiftc 退出代码 1 失败
以下构建命令失败:
CompileSwift 普通 arm64“项目文件夹路径”/custom_tableview_controller.swift
CompileSwiftSources 正常 arm64 com.apple.xcode.tools.swift.compiler (2 次失败)
尴尬的是在我的custom_tableview_controller.swift 文件工作之外的任何其他文件中调用UIDevice.currentDevice()。
附加信息:
- Xcode 6.4(6E35b)
- 调试
【问题讨论】:
-
请在您使用
UIDevice.currentDevice()的地方显示完整行 -
dsl_textfield_cell!.dsc_textfield.text = UIDevice.currentDevice().name是完整的行,但是当我在新行中写UIDevice.currentDevice()而不使用它时它也不会编译 -
很奇怪。相同的 Xcode 版本,它适用于我。建议:清理 Xcode(清理构建 + 清理派生数据)。
-
在 application(application: UIApplication, didFinishLaunchingWithOptions launchOptions: [NSObject: AnyObject]?) 中调用该行 -> Bool 正在工作。干净的构建 + 派生数据不起作用。