如何在iPhone设备中使用keychainwrapper

时间:2015-12-07 12:58:24

标签: ios keychainitemwrapper

当我在模拟器中使用它时它正在工作,但是当我在iPhone设备中运行它时不起作用。

为什么会这样,怎么做?

- (void) RememberUserAccount:(NSString *) userName password:(NSString *) password {
//NSString *uuid = [[NSUUID UUID] UUIDString];
NSString *identifierForVendor = [[UIDevice currentDevice].identifierForVendor UUIDString];
KeychainItemWrapper *keyWrapper=[[KeychainItemWrapper alloc]initWithIdentifier:identifierForVendor accessGroup:@"hello.lt"];
[keyWrapper setObject:userName forKey:(id)kSecAttrAccount];
[keyWrapper setObject:password forKey:(id)kSecValueData];

}

这是错误:

erminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'Couldn't add the Keychain Item.'

感谢!

0 个答案:

没有答案