Reference-counted object is used after it is released

Posted by EndyVelvet on Stack Overflow See other posts from Stack Overflow or by EndyVelvet
Published on 2012-04-01T17:02:23Z Indexed on 2012/04/01 17:29 UTC
Read the original article Hit count: 236

Filed under:
|
|

Doing code analysis of the project and get the message "Reference-counted object is used after it is released" on the line [defaults setObject: deviceUuid forKey: @ "deviceUuid"];

I watched this topic Obj-C, Reference-counted object is used after it is released? But the solution is not found. ARC disabled.

// Get the users Device Model, Display Name, Unique ID, Token & Version Number
UIDevice *dev = [UIDevice currentDevice];
NSString *deviceUuid;
if ([dev respondsToSelector:@selector(uniqueIdentifier)])
    deviceUuid = dev.uniqueIdentifier;
else {
    NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults];
    id uuid = [defaults objectForKey:@"deviceUuid"];
    if (uuid)
        deviceUuid = (NSString *)uuid;
    else {
        CFStringRef cfUuid = CFUUIDCreateString(NULL, CFUUIDCreate(NULL));
        deviceUuid = (NSString *)cfUuid;
        CFRelease(cfUuid);
        [defaults setObject:deviceUuid forKey:@"deviceUuid"];
    }
}

Please help find the cause.

© Stack Overflow or respective owner

Related posts about iphone

Related posts about objective-c