首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >快速UIDevice生成错误

快速UIDevice生成错误
EN

Stack Overflow用户
提问于 2016-03-09 09:59:07
回答 1查看 604关注 0票数 2

使用UIDevice类时,我会得到以下生成错误。

Command /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/swiftc failed with exit code 1

Global variable initializer type does not match global variable type! %struct._class_t** @"OBJC_CLASSLIST_REFERENCES_$_" LLVM ERROR: Broken module found, compilation aborted!

触发错误的代码是print(UIDevice.currentDevice())

我是做错什么了,还是有人知道解决办法?

是的,我已经导入了UIKit :)

*编辑*

下面是我使用的函数,注意注释掉的UIDevice引用修复了构建错误

代码语言:javascript
复制
func setAFHTTPRequestOperationManager(manager : AFHTTPRequestOperationManager) {
    manager.responseSerializer = AFJSONResponseSerializer()
    manager.requestSerializer = AFHTTPRequestSerializer()
    // This causes compile issue?
    uuid = (UIDevice.currentDevice().identifierForVendor?.UUIDString)!
    manager.requestSerializer.setValue(uuid, forKey: K.API.HeaderFields.DeviceToken)

    var types = NSSet()
    types = manager.responseSerializer.acceptableContentTypes
    types = types.setByAddingObject(K.API.HeaderFields.TextContentType)
    manager.responseSerializer.acceptableContentTypes = types as Set<NSObject>
    manager.requestSerializer.timeoutInterval = 30
    manager.requestSerializer.cachePolicy = NSURLRequestCachePolicy.ReloadIgnoringLocalAndRemoteCacheData
    afNetworkingManager = manager
}
EN

回答 1

Stack Overflow用户

发布于 2016-03-09 10:20:09

您是否也在某个地方使用UI_USER_INTERFACE_IDIOM()?如果是的话,尝试使用UIDevice.currentDevice().userInterfaceIdiom代替。

票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/35888309

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档