获取唯一UUID (第三方)

SFHFKeychainUtils (下载地址 https://github.com/ldandersen/scifihifi-iphone)是一个封装了KeyChain简单操作的第三方类库
1、引入Security.frameWork框架。

2、引入头文件:SFHKeychainUtils.h.(注意:SFHKeychainUtils为MRC,在ARC环境需配置如下)

获取唯一UUID (第三方)_第1张图片

3、方法如下

pragma mark -获取唯一UUID

  • (NSString*)UUID {

    NSDictionary *infoDict = [[NSBundle mainBundle] infoDictionary];

    NSString *userName = infoDict[@"CFBundleName"];

    NSString *serviceName = infoDict[@"CFBundleIdentifier"];

    NSString *UUID = [SFHFKeychainUtils getPasswordForUsername:userName andServiceName:serviceName error:nil];

    if (UUID.length==0) {

        UUID = [[[UIDevice currentDevice] identifierForVendor] UUIDString];
    
        [SFHFKeychainUtils storeUsername:userName andPassword:UUID forServiceName:serviceName updateExisting:1 error:nil];
    }
    returnUUID;
    

}

你可能感兴趣的:(获取唯一UUID (第三方))