iOS开发技巧:使用Objective-C创建UUID的代码
2011-11-29 20:57
681 查看
- (NSString *)createUUID
{
// Create universally unique identifier (object)
CFUUIDRef uuidObject = CFUUIDCreate(kCFAllocatorDefault);
// Get the string representation of CFUUID object.
NSString *uuidStr = [(NSString *)CFUUIDCreateString(kCFAllocatorDefault, uuidObject) autorelease];
// If needed, here is how to get a representation in bytes, returned as a structure
// typedef struct {
// UInt8 byte0;
// UInt8 byte1;
// ...
// UInt8 byte15;
// } CFUUIDBytes;
CFUUIDBytes bytes = CFUUIDGetUUIDBytes(uuidObject);
CFRelease(uuidObject);
return uuidStr;
}
{
// Create universally unique identifier (object)
CFUUIDRef uuidObject = CFUUIDCreate(kCFAllocatorDefault);
// Get the string representation of CFUUID object.
NSString *uuidStr = [(NSString *)CFUUIDCreateString(kCFAllocatorDefault, uuidObject) autorelease];
// If needed, here is how to get a representation in bytes, returned as a structure
// typedef struct {
// UInt8 byte0;
// UInt8 byte1;
// ...
// UInt8 byte15;
// } CFUUIDBytes;
CFUUIDBytes bytes = CFUUIDGetUUIDBytes(uuidObject);
CFRelease(uuidObject);
return uuidStr;
}
相关文章推荐
- iOS开发技巧:使用Objective-C创建UUID
- 使用Objective-C创建UUID的代码
- iOS开发技巧:PCH文件的创建于使用
- iOS开发技巧--使用CocoaPods创建、删除第三方框架
- iOS 开发-使用代码创建button
- 【iOS开发】使用代码创建UIButton
- iOS开发之使用Code Snippet创建代码片段
- iOS开发使用代码创建一个Label控件
- IOS开发-UI学习-使用代码创建button
- iOS开发:使用Xcode创建最简单的代码
- iOS开发之使用Code Snippet创建代码片段
- 针对iOS开发的一些Xcode使用技巧小结
- 【iOS开发必收藏】详解iOS应用程序内使用IAP/StoreKit付费、沙盒(SandBox)测试、创建测试账号流程!【2012-12-11日更新获取"产品付费数量等于0的问题"】
- 本篇文章,主要收录本人工作时iOS开发中代码写法的一些奇淫技巧,会持续更新中~
- iOS开发-使用代码退出应用程序,带动画。
- iOS开发中使用UILabel设置字体的相关技巧小结
- 设计模式之单一职责原则(iOS开发,代码用Objective-C展示)
- 【iOS开发必收藏】详解iOS应用程序内使用IAP/StoreKit付费、沙盒(SandBox)测试、创建测试账号流程!【2012-12-11日更新获取"产品付费数量等于0的问题"】
- Obj-C语言开发iOS项目使用反射减少代码工作
- ios开发UI篇—使用纯代码自定义UItableviewcell实现一个简单的微博界面布局