之前使用了KeyxhainitemWrapper出现了许多错误,后来使用了一个第三方SSkeychain,解决了问题:
下载:https://github.com/samsoffes/sskeychain/
参考文章:http://blog.sina.com.cn/s/blog_93f39bc20101a44t.html
引入SSKeychain.h和SSKeychain.m文件几Security.framework框架
- (NSString *)getUUIDBySSKeychain {
NSString *UUID = [SSKeychain passwordForService:@"com.yourapp.yourcompany"account:@"user"];
if (UUID.length == 0) {
CFUUIDRef uuid = CFUUIDCreate(NULL);
assert(uuid != NULL);
CFStringRef uuidStr = CFUUIDCreateString(NULL, uuid);
[SSKeychain setPassword: [NSString stringWithFormat:@"%@", uuidStr]
forService:@"com.yourapp.yourcompany"account:@"user"];
UUID = [SSKeychain passwordForService:@"com.yourapp.yourcompany"account:@"user"];
}
return UUID;
}