「ios入門」iosでudidを取得するサンプルコード

サンプルコード:
-(void) setKeyChainValue
{
KeychainItemWrapper *keyChainItem=[[KeychainItemWrapper alloc]initWithIdentifier:@"TestUUID" accessGroup:@"XXXXXX.h.こんにちは"];
NSString *strUUID = [keyChainItem objectForKey:(id)kSecValueData];
if (strUUID==nil||[strUUID isEqualToString:@""])
{
[keyChainItem setObject:[self gen_uuid] forKey:(id)kSecValueData];
}
[keyChainItem release];

}

-(NSString *) gen_uuid
{
CFUUIDRef uuid_ref=CFUUIDCreate(nil);
CFStringRef uuid_string_ref=CFUUIDCreateString(nil, uuid_ref);
CFRelease(uuid_ref);
NSString *uuid=[NSString stringWithString:uuid_string_ref];
CFRelease(uuid_string_ref);
return uuid;
}

keychainを操作するツール

https://developer.apple.com/library/ios/samplecode/GenericKeychain/Listings/Classes_KeychainItemWrapper_m.html

 

IOS

Posted by arkgame