Contents

Develop
2016.05.13 11:17

[ios] UUID 생성 + Key Chain 연동

조회 수 4760 댓글 0
?

단축키

Prev이전 문서

Next다음 문서

크게 작게 위로 아래로 댓글로 가기 인쇄
?

단축키

Prev이전 문서

Next다음 문서

크게 작게 위로 아래로 댓글로 가기 인쇄

UUID 쉽게 사용하기 ㅋㅋ


KeychainItemWrapper.h/m 파일은 업로드된 것을 사용해도 되고 아래 URL에 있는 내용을 사용해도 됨.

(어차피 업로드 된 것도 저거 다운 받아서 업로드 한거니.. ㅋㅋ)


# KeychainItemWrapper.h 파일

https://developer.apple.com/library/ios/samplecode/GenericKeychain/Listings/Classes_KeychainItemWrapper_h.html


# KeychainItemWrapper.m 파일

https://developer.apple.com/library/ios/samplecode/GenericKeychain/Listings/Classes_KeychainItemWrapper_m.html


#import "KeychainItemWrapper.h"

- (NSString *)getDeviceUUID {
    KeychainItemWrapper *keychainItemWrapper =
    [[KeychainItemWrapper alloc] initWithIdentifier:@"UUID-Identifier" accessGroup:nil];
    NSString *uuidString = [keychainItemWrapper objectForKey:(__bridge id)(kSecAttrAccount)];
    
    if (uuidString == nil || [uuidString length] == 0) {
        // if there is not UUID in keychain, make UUID and save it.
        CFUUIDRef uuidRef = CFUUIDCreate(NULL);
        CFStringRef uuidStringRef = CFUUIDCreateString(NULL, uuidRef);
        CFRelease(uuidRef);
        uuidString = [NSString stringWithString:(__bridge NSString *)uuidStringRef];
        CFRelease(uuidStringRef);
        
        // save UUID in keychain
        [keychainItemWrapper setObject:uuidString forKey:(__bridge id)(kSecAttrAccount)];
    }
    
    return uuidString;
}



?

List of Articles
번호 분류 제목 글쓴이 날짜 조회 수
637 Develop [ios] Objective-C 프로퍼티의 ATOMIC / NONATOMIC 속성 hooni 2014.03.17 3033
636 Develop [ios] UDID 사용 제한에 따른 대안들 hooni 2014.03.13 4008
635 Develop [ios] URL Scheme 이용하여 앱 설치 확인 hooni 2014.03.10 4406
634 Develop SVN 초간단 사용하기 hooni 2014.02.28 7674
633 Develop SVN 명령어 (SVN command) hooni 2014.02.28 12196
632 Develop 페이팔에서 돈 찾기 (Paypal withdraw) file hooni 2014.02.20 11457
631 Develop [unix] 유닉스 명령에 메타문자 사용 hooni 2014.02.19 11296
630 Develop [unix] Java 애플릿용 HTML 자동 생성 hooni 2014.02.19 8261
629 Develop [unix] 로그파일 정리 쉘스크립트 hooni 2014.02.19 10860
628 Develop [html] SVG(Scalable Vector Graphics) 간단 정리 hooni 2014.02.13 8860
627 Develop [php] XE 관리자 IP대역 설정 오류 해결법 hooni 2014.02.10 10815
626 Develop [c] 64bit 머신에서 inet_ntoa() 사용시 Segment fault 대처 방법법 hooni 2014.02.08 14258
Board Pagination Prev 1 ... 13 14 15 16 17 18 19 20 21 22 ... 71 Next
/ 71