我有一个快速项目,在该项目中,我希望检索设备的名称并在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 normal arm64 com.apple.xcode.tools.swift.compiler (2次失败)
尴尬的是,在我的UIDevice.currentDevice()文件之外的任何文件中调用custom_tableview_controller.swift都是有效的。
其他信息:
发布于 2016-01-02 14:23:34
我用Swift在框架中创建了get UIDevice:
创建Obj-c Header.h并添加
#import <UIKit/UIKit.h>
/**
* Static Current Device
* @note Can't get UIDevice CurrentDevice in Swift, Hack with obj-c
*
* @return UIDevice
*/
static UIDevice* Device() { return [UIDevice currentDevice]; }目标框架中的 ->构建阶段使以下内容成为:

目标框架中的.h添加:
#import <BSStaticObjc.h>现在在Swift调用方法
Device()发布于 2015-09-15 18:11:04
这也把我逼疯了。我不能修好它。作为一种解决办法,我创建了一个目标-C类,它仅仅是sublcasses。我的班是AWDevice。在Swift中,编译器对AWDevice.currentDevice()很满意
这真的很奇怪。
https://stackoverflow.com/questions/32312378
复制相似问题