Cut the crap and put it in the chase:
Recently in the study to achieve the acquisition device unique identifier, through various aspects of research, found that the use of Apple's official recommended keychain is quite good.
Apple provides an example program called Generickeychain, here: http://developer.apple.com/library/ios/#samplecode/generickeychain/ Listings/classes_keychainitemwrapper_h.html#//apple_ref/doc/uid/dts40007797-classes_keychainitemwrapper_ H-dontlinkelementid_9, which encapsulates a class that simplifies keychain operations: Keychainitemwrapper, can be used directly, remember to join the security.framework! Under The Spit Groove. The Apple demo also has a memory leak and does not fit the arc, so there is a warning to remember to add-FNO-OBJC-ARC after the build phases. m file.
and open keychain sharing in the capabilities, The new version of Xcode will automatically generate a name.entitlements file, the old version will need to create a new Keychainaccessgroups.plist file in the project directory, the top-most node in the structure of the file must be a named " Keychain-access-groups "Array, and each item in the array is a nsstring that describes the grouping. There are also requirements for the format of string: "AppIdentifier.com.xxxx.name", where Appidentifier is the ID of your developer account.
Appidentifier This new version of Xcode to go to the keychain to find. 1. Open Keychain 2. Select My certificate 3. Look at the name of the certificate you are using (XXXXXX) The 10 uppercase letters are what we are looking for.
It is wrong to write the error.
The following in a public class add
/*
uiID
*/
+ (NSString *) getuuid
{
Keychainitemwrapper *keychainitem = [[Keychainitemwrapper alloc]
initwithidentifier:@ "UUID"
accessgroup:@ "4vxzqb2w6t.com.yjxh.pengsi"];//your_bundle_seed.
NSString *struuid = [Keychainitem objectforkey: (ID) cfbridgingrelease (ksecvaluedata)];
When the method is first executed, the UUID is empty
if ([Struuid isequaltostring:@ ""])
{
Cfuuidref uuidref = cfuuidcreate (Kcfallocatordefault);
Struuid = (NSString *) cfbridgingrelease (cfuuidcreatestring (kcfallocatordefault,uuidref));
[Keychainitem setobject:struuid Forkey: (ID) Cfbridgingrelease (Ksecvaluedata)];
}
return struuid;
}
It's OK.
Realize this function to draw on a few aunt's articles
The links are as follows:
Http://www.cnblogs.com/smileEvday/p/UDID.html#!comments
Http://blog.k-res.net/archives/1081.html
Copyright NOTICE: This article for Bo Master original article, without Bo Master permission not reproduced.
Keychain in iOS implements the UUID device unique identifier encountered problem