Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/swift/17.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/xpath/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Ios Swift UIDevice.currentDevice()未编译_Ios_Swift_Uidevice - Fatal编程技术网

Ios Swift UIDevice.currentDevice()未编译

Ios Swift UIDevice.currentDevice()未编译,ios,swift,uidevice,Ios,Swift,Uidevice,我有一个swift项目,我想在其中检索设备的名称并显示在UITableViewCell 但是当我想在中调用UIDevice.currentDevice() override func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell 编译器失败,原因是: 命令 /Applications/Xcode.app/Contents/Develope

我有一个swift项目,我想在其中检索设备的名称并显示在
UITableViewCell


但是当我想在中调用
UIDevice.currentDevice()

override func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell
编译器失败,原因是:

命令 /Applications/Xcode.app/Contents/Developer/toolschains/xcodefault.xctoolschain/usr/bin/swiftc 失败,退出代码为1

以下生成命令失败:
编译Wift普通arm64“项目文件夹路径”/custom\u tableview\u controller.swift
CompileSwiftSources普通arm64 com.apple.xcode.tools.swift.compiler (2次失败)


尴尬的事情是在任何其他文件中调用
UIDevice.currentDevice()
,而不是在我的
custom\u tableview\u controller.swift
文件正在工作

其他信息:
-Xcode 6.4(6E35b)

-调试

这也让我抓狂。我修不好。作为一种解决方法,我创建了一个Objective-C类,该类只对UIDevice进行子类化。我的班级是
AWDevice
。在Swift中,编译器对
AWDevice.currentDevice()


这真的很奇怪。

我用Swift为框架中的get-UIDevice创建了一个:

创建Obj-c标题.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]; }

请显示使用
UIDevice.currentDevice()
dsl\u textfield\u cell!的完整行!。dsc_textfield.text=UIDevice.currentDevice().name
是整行,但如果我只在新行中写入
UIDevice.currentDevice()
,而不使用它,它也不会编译。同样的Xcode版本,对我来说也很管用。建议:清理Xcode(清理构建+清理派生数据)。调用应用程序中的行(应用程序:UIApplication,didFinishLaunchingWithOptions launchOptions:[NSObject:AnyObject]?)->Bool正在工作。干净的构建+派生数据不起作用。太好了!我也有同样的问题。我花了相当长的时间注释掉了几乎一半的源代码,直到发现UIDevice导致了编译问题。我第一次在Stackoverflow上搜索编译器消息以寻找解决方案,但没有成功。因此,对于具有相同问题的其他人,以下是此错误的编译器错误:
全局变量初始值设定项类型与全局变量类型不匹配!%struct.\u class\u t**@“OBJC\u CLASSLIST\u REFERENCES\u$\ uVM”LLVM错误:找到损坏的模块,编译中止请注意:您需要选择所有消息才能看到此错误
#import <BSStaticObjc.h>
Device()