ios-UUID静态会话的问题

我想要给UUID使用一个替换方式:

+ (NSString *)GetUUID
{
  CFUUIDRef theUUID = CFUUIDCreate(NULL);
  CFStringRef string = CFUUIDCreateString(NULL, theUUID);
  CFRelease(theUUID);
  return [(NSString *)string autorelease];
}

但是在模拟器中每个会话给出的结果都不一样。
这是只在模拟器中发生的吗?

我需要在实际设备上每次都返回同样的字符串来识别用户。

CFUUIDRef 在不同会话中会出现不同值。

解决方法1:

在NSUserDefaults中保存值,下次使用的时候从NSUserDefaults中找。

2:

可以使用identifierForVendor 来实现。

NSString *udidVendor = [[[UIDevice currentDevice] identifierForVendor] UUIDString];

看一下这里的说明:http://developer.apple.com/library/ios/#documentation/uikit/reference/UIDevice_Class/Reference/UIDevice.html