使用Objective-C创建UUID的代码
2016-06-01 13:57
465 查看
UUID含义是通用唯一识别码 (Universally Unique Identifier),这 是一个软件建构的标准,也是被开源软件基金会 (Open Software Foundation, OSF) 的组织在分布式计算环境 (Distributed Computing Environment, DCE) 领域的一部份。
UUID 的目的,是让分布式系统中的所有元素,都能有唯一的辨识资讯,而不需要透过中央控制端来做辨识资讯的指定。如此一来,每个人都可以建立不与其它人冲突的 UUID。在这样的情况下,就不需考虑数据库建立时的名称重复问题。目前最广泛应用的
UUID,即是微软的 Microsoft's Globally Unique Identifiers (GUIDs),而其他重要的应用,则有 Linux ext2/ext3 档案系统、LUKS 加密分割区、GNOME、KDE、Mac
OS X 等等。
- (NSString *)createUUID
{
// Create
universally unique identifier (object)
CFUUIDRef uuidObject = CFUUIDCreate(kCFAllocatorDefault);
NSString *uuidStr = [(NSString *)CFUUIDCreateString(kCFAllocatorDefault,
uuidObject) autorelease];
CFUUIDBytes bytes = CFUUIDGetUUIDBytes(uuidObject);
CFRelease(uuidObject);
return uuidStr;
}
UUID 的目的,是让分布式系统中的所有元素,都能有唯一的辨识资讯,而不需要透过中央控制端来做辨识资讯的指定。如此一来,每个人都可以建立不与其它人冲突的 UUID。在这样的情况下,就不需考虑数据库建立时的名称重复问题。目前最广泛应用的
UUID,即是微软的 Microsoft's Globally Unique Identifiers (GUIDs),而其他重要的应用,则有 Linux ext2/ext3 档案系统、LUKS 加密分割区、GNOME、KDE、Mac
OS X 等等。
- (NSString *)createUUID
{
// Create
universally unique identifier (object)
CFUUIDRef uuidObject = CFUUIDCreate(kCFAllocatorDefault);
NSString *uuidStr = [(NSString *)CFUUIDCreateString(kCFAllocatorDefault,
uuidObject) autorelease];
CFUUIDBytes bytes = CFUUIDGetUUIDBytes(uuidObject);
CFRelease(uuidObject);
return uuidStr;
}
相关文章推荐
- 关于JSONArray:JSONArray jsonArray=JSONArray.fromObject(list)不执行!
- java中Array/List/Map/Object与Json互相转换详解
- Object
- setter=method @property(getter = getMethodName, setter = setMethodName) Object *obj;
- 精通Objective-C 第一章~第三章读书笔记
- 使用Object-C实现23种设计模式之适配器模式
- Handle and Object Functions--句柄和对象函数
- 使用对象流读写对象代码笔记(ObjectInputStream ,ObjectOutputStream)
- Color-based object detection using Hue and Saturation thresholding
- PHP“Cannot use object of type stdClass as array”
- Objective-C Runtime method swizzling简介(翻译)
- Java基础知识:java.lang包-Object、String、StringBuffer和包装类等
- import json后,报错:AttributeError: 'module' object has no attribute 'dumps,原因分析及解决方法
- OpenGL中的Frame Buffer Object 理解
- String 转换成JSONObject
- Objective-C 编程全解-第03章 类和继承
- JSONObject和JSONArray
- Android实现动画过程中遇到View.mViewFlags on null object refrence
- JsonObject生成Json字符串,并且解析为对象-----JsonReader解析Json字符串
- could not reserve enough space for object heap