开发者

Do I need to release an NSString created by CFUUIDCreateString()?

开发者 https://www.devze.com 2023-04-04 04:51 出处:网络
I am creating a NSString like this, should I release it afterwards or not? CFUUIDRefuuidObj = CFUUIDCreate(nil);

I am creating a NSString like this, should I release it afterwards or not?

CFUUIDRef   uuidObj = CFUUIDCreate(nil);
        NSString *device = (NSString*)CFU开发者_运维百科UIDCreateString(nil, uuidObj);
        CFRelease(uuidObj);

Thanks!


Here is documentation for this function:

CFUUID Reference - CFUUIDCreateString

and it states that ownership follows The Create Rule.

Here are some more links with answer:

  • Memory management with CF Objects
  • Strings from UUID


CFUUIDRef theUUID = CFUUIDCreate(NULL);

NSString *s2ndUuid = (__bridge_transfer NSString*)CFUUIDCreateString(kCFAllocatorDefault, theUUID);
0

精彩评论

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