获取iPhone的唯一标识符

- (NSString *)getDeviceIdfa

{

    NSString*strUUID = (NSString*)[KeyChainStore load:KEY_USERNAME_PASSWORD];//从我自己钥匙串中获取是否有存入值

  //首次执行该方法时,uuid为空

    if([strUUID isEqualToString:@""]|| !strUUID)

    {

        //生成一个uuid的方法

        CFUUIDRef uuidRef= CFUUIDCreate(kCFAllocatorDefault);

        strUUID = (NSString*)CFBridgingRelease(CFUUIDCreateString(kCFAllocatorDefault,uuidRef));

 //将该uuid保存到keychain

        [KeyChainStore save:KEY_USERNAME_PASSWORD data:strUUID];

    }

    return strUUID;

}

你可能感兴趣的:(获取iPhone的唯一标识符)