开发者

Convert iPhone unique identifier to integer

I have made a web service that gets an integer as a unique identifier for a Phone. Later, i realised that an iPhone UID is an NSstring in that format: 5DE31FA12-XXXXX-XXXXX-XXXXXXX. So i would like to convert this value t开发者_StackOverflow社区o an integer.

Here is the way i get the UID in a NSString format.

CFUUIDRef theUUID = CFUUIDCreate(NULL);
CFStringRef string = CFUUIDCreateString(NULL, theUUID);
CFRelease(theUUID);
NSString *theUID = (NSString *)string;

How can i convert NSString *theUID into an integer value, so as to send it to the webservice?

EDIT: As CocoaFu correctly mentioned , it is impossible to fit that value in an int. Could I somehow convert it to an NSString with a format like "ddddddddddddddddddddddddddd" (where d = 0-9) so as to hash it and then send it? It is impossible to change the webservice now.


The largest integer is 8 bytes or 64 bits. The UUID you show has 26 hex characters which is 104 bits. It just won't fit in an integer. Use the string.

CFUUIDCreate returns a string with 32 hex characters, that is 128 bits or 16 bytes. Ignore the '-' characters, they are just for human readability. Here is an example from CFUUIDCreate: BDFC3FE6-3A5E-48C0-B18D-E42B8E275428


UDID won't fit in an int. The format you have listed is what the simulator gives you. Device UDID is 40-characters long alpha-numeric.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜