031-钥匙串访问以及相关框架

导入 SAMKeychain 库
配置到 路径

封装DeviceId的类

//
// MYIDeviceld.h
// EPStore
//
// Created by ArrQ on 2017/2/21.
// Copyright © 2017年 zhifenx. All rights reserved.
//

#import 

@interface MYIDeviceld : NSObject
/**
 
 获取设备的 UUID
 
 @return UUID 字符串
 */

+ (NSString *)getDeviceId;

@end

//
//  MYIDeviceld.m
//  EPStore
//
//  Created by ArrQ on 2017/2/21.
//  Copyright © 2017年 zhifenx. All rights reserved.
//

#import "MYIDeviceld.h"
#import "SAMKeychain.h"
@implementation MYIDeviceld
+ (NSString *)getDeviceId{
    NSString *currentDeviceUUIDString = [SAMKeychain passwordForService:@"www.youshengedu.net" account:@"uuid"];
    if (!currentDeviceUUIDString) {
        
//        NSUUID *currentDeviceUUID  = [UIDevice currentDevice].identifierForVendor;
//        currentDeviceUUIDString = currentDeviceUUID.UUIDString;
//        [SAMKeychain setPassword:currentDeviceUUIDString forService:@"www.youshengedu.net"account:@"uuid"];
    }
    return currentDeviceUUIDString;
}
@end

你可能感兴趣的:(031-钥匙串访问以及相关框架)