1. 키체인에서 사용하는 App Id 코드로 얻어오기
extension UIApplication {
class var bundleSeedId: String {
struct Static {
static var token : dispatch_once_t = 0
static var identifier: String!
}
dispatch_once(&Static.token) {
let query: NSDictionary = NSDictionary(objects: [kSecClassGenericPassword, "Bundle Seed ID", kCFBooleanTrue], forKeys: [String(kSecClass), String(kSecAttrAccount), String(kSecReturnAttributes)])
var result: AnyObject?
var status: OSStatus = SecItemCopyMatching(query as CFDictionaryRef, &result)
if status == errSecItemNotFound {
status = SecItemAdd(query as CFDictionaryRef, &result);
}
if status == errSecSuccess {
if let dic = result as? NSDictionary {
if let accessGroup = dic[kSecAttrAccessGroup as NSString] as? NSString {
let components = accessGroup.componentsSeparatedByString(".")
Static.identifier = components[0] as String
}
}
}
}
return Static.identifier
}
}
사용법
let bundleSeedId = UIApplication.bundleSeedId
NSBundle.mainBundle().objectForInfoDictionaryKey("AppIdentifierPrefix"))
'iOS > 참고' 카테고리의 다른 글
[발번] Swift Style Guide (raywenderlich) (1) | 2016.07.12 |
---|---|
iOS bundle Seed Id 얻어오기 (0) | 2016.07.12 |
iOS 스와이프로 뒤로 가기 처리 (0) | 2016.07.12 |
iOS 캘린더 사용하기 (0) | 2016.07.12 |
iOS WebView 서버 로그 보려면 (0) | 2016.07.12 |
iOS9 에서 http 사용하기 (0) | 2016.03.14 |
댓글을 달아 주세요