zoukankan      html  css  js  c++  java
  • 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
  • 相关阅读:
    linux查找某个命令属于哪个rpm包
    dashboard安装
    yum下载的rpm包离线安装
    jQuery的选择器
    jQuery介绍
    client、offset、scroll系列
    BOM
    js 中的定时器
    JS中的面相对象
    关于DOM操作的相关案例
  • 原文地址:https://www.cnblogs.com/ihojin/p/uuid-sskeychain.html
Copyright © 2011-2022 走看看