Recent project development, the use of to get UUID to MD5, but iOS7 can not use the obtained Udid interface (related to privacy), the way to obtain the MAC address of the interface under IOS7 also discarded. Now it's possible to get the UUID, but under the iOS7, UUID a bad place is every time the call, the generated is not the same, this will cause once the app unloaded load, the UUID changed.
Here is a more convenient way to solve this problem:
1. Import security.framework
2. On GitHub http://github.com/soffes/sskeychain Download the Sskeychain Open Source Library and introduce the Sskeychain directory to your project
-(NSString *) getiosuuid{ nsstring *retrieveuuid = [Sskeychain passwordforservice:@ "Com.mohe.userinfo" account:@ " UUID "]; if (Retrieveuuid = = Nil | | [Retrieveuuid isequaltostring:@ ""]) { Cfuuidref uuid = cfuuidcreate (NULL); ASSERT (uuid = NULL); Cfstringref uuidstr = cfuuidcreatestring (NULL, uuid); Retrieveuuid = [NSString stringwithformat:@ "%@", uuidstr]; [Sskeychain setpassword:retrieveuuid forservice:@ "com.mohe.userinfo" account:@ "uuid"]; } return retrieveuuid;}
@ Convert MD5 format words can write a category:
#import "Nsstring+md5.h" #import <CommonCrypto/CommonDigest.h> @implementation nsstring (MD5)-(NSString *) md5hexdigest{ const char *ORIGINAL_STR = [self utf8string]; unsigned char result[cc_md5_digest_length]; CC_MD5 (ORIGINAL_STR, (int) strlen (ORIGINAL_STR), result); nsmutablestring *hash = [nsmutablestring string]; for (int i = 0; i < i++) [hash appendformat:@ "%02x", Result[i]]; return [hash lowercasestring];} @end
@ test found that the UUID after deletion will still change, behind Baidu this blog, we can participate in:
Http://www.cnblogs.com/smileEvday/p/UDID.html
IOS7 get uuid and convert MD5