得到bundle seed id

时间:2023-11-09 23:27:32

- (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;

}