你好,歡迎來到IOS教程網

 Ios教程網 >> IOS編程開發 >> IOS開發綜合 >> iOS中CFUUIDRef,CFUUIDCreate聲稱唯一字符串

iOS中CFUUIDRef,CFUUIDCreate聲稱唯一字符串

編輯:IOS開發綜合

CFUUIDRef theUUID = CFUUIDCreate(NULL);

CFStringRef guid = CFUUIDCreateString(NULL, theUUID);

CFRelease(theUUID);

NSString *uuidString = [((NSString *)guid) stringByReplacingOccurrencesOfString:@"-" withString:@""];

CFRelease(guid);

為了能標識該字符串,所以一般使用一個固定的字符串來標志

- (NSString *)pathForTemporaryFileWithPrefix:(NSString *)prefix

{

NSString * result;

CFUUIDRef uuid;

CFStringRef uuidStr;

uuid = CFUUIDCreate(NULL);

assert(uuid != NULL);

uuidStr = CFUUIDCreateString(NULL, uuid);

assert(uuidStr != NULL);

result = [NSTemporaryDirectory()stringByAppendingPathComponent:[NSStringstringWithFormat:@"%@-%@", prefix, uuidStr]];

assert(result != nil);

CFRelease(uuidStr);

CFRelease(uuid);

return result;

}



  1. 上一頁:
  2. 下一頁:
蘋果刷機越獄教程| IOS教程問題解答| IOS技巧綜合| IOS7技巧| IOS8教程
Copyright © Ios教程網 All Rights Reserved