首页 > 代码库 > 得到bundle seed id

得到bundle seed id

- (NSString *)bundleSeedID {

    NSDictionary *query = [NSDictionary dictionaryWithObjectsAndKeys:

                           (__bridge id)(kSecClassGenericPassword), kSecClass,

                           @"bundleSeedID", kSecAttrAccount,

                           @"", kSecAttrService,

                           (id)kCFBooleanTrue, kSecReturnAttributes,

                           nil];

    CFDictionaryRef result = nil;

    OSStatus status = SecItemCopyMatching((__bridge CFDictionaryRef)query, (CFTypeRef *)&result);

    if (status == errSecItemNotFound)

        status = SecItemAdd((__bridge CFDictionaryRef)query, (CFTypeRef *)&result);

    if (status != errSecSuccess)

        return nil;

    NSString *accessGroup = [(__bridge NSDictionary *)result objectForKey:(__bridge id)(kSecAttrAccessGroup)];

    NSArray *components = [accessGroup componentsSeparatedByString:@"."];

    NSString *bundleSeedID = [[components objectEnumerator] nextObject];

    CFRelease(result);

    return bundleSeedID;

}

得到bundle seed id