首页 > 移动平台 > 详细

iOS中CFUUIDRef,CFUUIDCreate声称唯一字符串

时间:2014-04-04 22:24:35      阅读:855      评论:0      收藏:0      [点我收藏+]

  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;

}



iOS中CFUUIDRef,CFUUIDCreate声称唯一字符串,布布扣,bubuko.com

iOS中CFUUIDRef,CFUUIDCreate声称唯一字符串

原文:http://blog.csdn.net/u012795030/article/details/22947613

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!