iOS 生成UUID
示例
随机UUID
迅速
func randomUUID() -> NSString{return NSUUID.UUID().UUIDString()}
目标C
+ (NSString *)randomUUID {if(NSClassFromString(@"NSUUID")) { // only available in iOS >= 6.0
return [[NSUUID UUID] UUIDString];
}
CFUUIDRef uuidRef = CFUUIDCreate(kCFAllocatorDefault);
CFStringRef cfuuid = CFUUIDCreateString(kCFAllocatorDefault, uuidRef); CFRelease(uuidRef);
NSString *uuid = [((__bridge NSString *) cfuuid) copy]; CFRelease(cfuuid);
return uuid;
}
以上是 iOS 生成UUID 的全部内容, 来源链接: utcz.com/z/361111.html