如何在 Objective C (iOS) 中创建 UUID 类型 1
我使用以下代码创建了 UUID(不知道哪种类型):
// Create universally unique identifier (object)
CFUUIDRef uuidObject = CFUUIDCreate(kCFAllocatorDefault);
// Get the string representation of CFUUID object.
NSString *uuidStr = (__bridge NSString *)CFUUIDCreateString(kCFAllocatorDefault, uuidObject);
CFRelease(uuidObject);
但是我发送数据的 API 表示它不是它需要的类型 1 http://en.wikipedia.org/wiki/Universally_unique_identifier#Version_1_.28MAC_address.29。
如何在 objC (iphone) 中创建这个 type1 UUID?
我在 obj C 中制作此文件时遇到问题,是否可以选择使用 C 代码来生成此文件?
I created UUID (don't know which type) with the following code:
// Create universally unique identifier (object)
CFUUIDRef uuidObject = CFUUIDCreate(kCFAllocatorDefault);
// Get the string representation of CFUUID object.
NSString *uuidStr = (__bridge NSString *)CFUUIDCreateString(kCFAllocatorDefault, uuidObject);
CFRelease(uuidObject);
But my API that is send data to says that is not type 1 that it needs http://en.wikipedia.org/wiki/Universally_unique_identifier#Version_1_.28MAC_address.29.
How to create this type1 UUID in objC (iphone)?
I have problems making this in obj C, is it an option to use C code to generate this?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
我一直在寻找同样的东西。这是:
uuid_generate_time
https://developer.apple.com/library/ios/documentation/System/Conceptual/ManPages_iPhoneOS/man3/uuid_generate_time.3.html
另外还有此函数的 Apple 源代码:
http://www.opensource.apple.com/source/xnu/xnu-792.13.8/libkern/uuid/uuid.c
I've been searching for the same thing. Here it is:
uuid_generate_time
https://developer.apple.com/library/ios/documentation/System/Conceptual/ManPages_iPhoneOS/man3/uuid_generate_time.3.html
Also there's Apple source code for this function:
http://www.opensource.apple.com/source/xnu/xnu-792.13.8/libkern/uuid/uuid.c
首先获取 MAC 地址:(来自 developertips)
然后使用以下命令生成 UUIDv1: rfc4122规范,如果规范太长而难以阅读,您可以从其他语言移植代码,这是我找到的:https://github.com/fredriklindberg/class.uuid.php/blob/master/class.uuid.php
Get the MAC address first: (from developertips)
Then generate the UUIDv1 with the rfc4122 spec, if the spec is too long to read, you may port the code from other language, here's one that I found: https://github.com/fredriklindberg/class.uuid.php/blob/master/class.uuid.php
使用以下函数您可以创建动态 UUID。
希望这有帮助..
Using following function you can create dynamic UUID.
Hope this helps..