首页 > 代码库 > iOS生成UUID

iOS生成UUID


//内连,使用情况较多下使用,

staticinline NSString * GetUUIDString()

{

   CFUUIDRef uuidObj = CFUUIDCreate(nil);

   NSString *uuidString = (__bridge_transfer NSString*)CFUUIDCreateString(nil, uuidObj);

   CFRelease(uuidObj);

   return uuidString;

}



//类方法,建议新建NSString的分类使用,

+ (NSString*) getUUIDString

{

   CFUUIDRef uuidObj = CFUUIDCreate(nil);

   NSString *uuidString = (__bridge_transfer NSString*)CFUUIDCreateString(nil, uuidObj);

   CFRelease(uuidObj);

   return uuidString;

}



iOS生成UUID