• iOS: UUID and SSKeyChain


    需要加入SSKeyChain文件

    传送门:SSKeyChain

    //
    //  UniqueIDCreater.h
    //  Housemart
    //
    //  Created by Haozhen Li on 13-9-26.
    //  Copyright (c) 2013年 refineit.com.cn. All rights reserved.
    //
    
    #import <Foundation/Foundation.h>
    #import "SSKeychain.h"
    
    @interface UniqueIDCreater : NSObject
    
    + (NSString *)uuid;
    @end
    //
    //  UniqueIDCreater.m
    //  Housemart
    //
    //  Created by Haozhen Li on 13-9-26.
    //  Copyright (c) 2013年 refineit.com.cn. All rights reserved.
    //
    
    #import "UniqueIDCreater.h"
    
    @implementation UniqueIDCreater
    
    #define kServiceKey @"com.housemart.housemart"
    #define kAccountKey @"user"
    
    + (NSString *)uuid
    {
        NSString *_uuid = nil;
        _uuid = [SSKeychain passwordForService:kServiceKey account:kAccountKey];
        if (_uuid == nil) {
            CFUUIDRef theUUID = CFUUIDCreate(NULL);
            CFStringRef string = CFUUIDCreateString(NULL, theUUID);
            CFRelease(theUUID);
            
            _uuid = [(NSString *)string autorelease];
            [SSKeychain setPassword:_uuid forService:kServiceKey account:kAccountKey];
        }
        
    //    NSLog(@"[%@ %@] = %@", NSStringFromClass([self class]), NSStringFromSelector(_cmd), _uuid);
        
        return _uuid;
    }
    @end
  • 相关阅读:
    集合异常原因与处理方式
    List的子类特点
    数据结构:数据的组织方式
    java对多态的了解
    JAVA电话本系统
    字符串转换数组
    登录用户名密码是否合法
    十三 spark 集群测试与基本命令
    十二 flume与kafka数据传输
    十一 spark- Standalone 集群
  • 原文地址:https://www.cnblogs.com/ihojin/p/uuid-sskeychain.html
Copyright © 2020-2023  润新知