iOS - UUID代抛出一个奇怪的异常 [英] iOS - UUID generation throwing a strange exception
问题描述
我正在尝试使用 https://github.com/gekitz / UIDevice-with-UniqueIdentifier-for-iOS-5 生成全局标识符。当我在git中尝试该示例时,它工作正常并正确显示标识符。但是,当我尝试将文件合并到一个新项目时,它不起作用!
I am trying to use https://github.com/gekitz/UIDevice-with-UniqueIdentifier-for-iOS-5 to generate a global identifier. When I try the sample in git it works fine and displays an identifier correctly. But when I try to incorporate the files into a new project it does not work!
我已经包含 -
#import "UIDevice+IdentifierAddition.h"
in my SampleAppDelegate.m,复制粘贴项目中的所有文件,并使用
in my SampleAppDelegate.m, copy pasted all files in the project, and am using
NSString *di = [[UIDevice currentDevice] uniqueGlobalDeviceIdentifier];
。我在uniqueGlobalDeviceIdentifier方法的第一行放了一个断点,但它永远不会到达!我错过了什么吗?
in the init method. I put a breakpoint on the first line of uniqueGlobalDeviceIdentifier method, but it is never reached! Am I missing something?
编辑:
异常 -
Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[UIDevice uniqueGlobalDeviceIdentifier]: unrecognized selector sent to instance 0x68170c0'
推荐答案
看起来像 UIDevice + IdentifierAddition.m
未编译。要检查/添加它:
It looks like UIDevice+IdentifierAddition.m
is not being compiled. To check / add it:
- 点击Xcode左侧导航器中的项目。
- 选择应用目标。
- 选择'Build Phases'选项卡。
- 打开'Compile Sources'。
- 检查
UIDevice + IdentifierAddition.m
是否存在。如果没有,则单击+,选择它并单击添加。
- Click on the project in the navigator on the left in Xcode.
- Select the app target.
- Select the 'Build Phases' tab.
- Open up 'Compile Sources'.
- Check that
UIDevice+IdentifierAddition.m
is in there. If not, then click the '+', select it and click add.
该异常指向此作为修复,因为它说的是 UIDevice
上没有方法,名为 uniqueGlobalDeviceIdentifier
,由类别添加。
The exception points to this as the fix because it's saying that there is no method on UIDevice
called uniqueGlobalDeviceIdentifier
, which is added by the category.
这篇关于iOS - UUID代抛出一个奇怪的异常的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!