Do I need to release an NSString created by CFUUIDCreateString()?
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);
精彩评论