iOS - UUID generation throwing a strange exception

强颜欢笑 提交于 2019-12-06 09:13:38

问题


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!

I have included -

#import "UIDevice+IdentifierAddition.h"

in my SampleAppDelegate.m, copy pasted all files in the project, and am using

NSString *di = [[UIDevice currentDevice] 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?

EDIT:

Exception -

Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[UIDevice uniqueGlobalDeviceIdentifier]: unrecognized selector sent to instance 0x68170c0'

回答1:


It looks like UIDevice+IdentifierAddition.m is not being compiled. To check / add it:

  1. Click on the project in the navigator on the left in Xcode.
  2. Select the app target.
  3. Select the 'Build Phases' tab.
  4. Open up 'Compile Sources'.
  5. Check that UIDevice+IdentifierAddition.m is in there. If not, then click the '+', select it and click add.

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.



来源:https://stackoverflow.com/questions/9897162/ios-uuid-generation-throwing-a-strange-exception

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!