将 32 位 Hex 字符串的 UUID 转换为 Base32 短字符串,并反向转换。
/* Generate UUID */
NSUUID *UUID = [NSUUID UUID];
NSString *UUIDString = UUID.UUIDString;
NSLog(@"Original UUID:\t%@", UUIDString);
// => Original UUID: 40256F2F-3211-49CD-BC1F-DD5197D2F0F9
/* Shorten UUID string */
NSString *shortUUIDString = UUID.shortUUIDString;
NSLog(@"Short UUID:\t%@", shortUUIDString);
// => Short UUID: IASW6LZSCFE43PA73VIZPUXQ7E
/* Restore UUID string from short string */
NSString *restoredString = [NSUUID UUIDStringFromShortUUIDString:shortUUIDString];
NSLog(@"Restored UUID:\t%@", restoredString);
// => Restored UUID: 40256F2F-3211-49CD-BC1F-DD5197D2F0F9
UUIDShortener.h
和 UUIDShortener.m
)复制到您的项目中。MIT 许可证