Search code examples
objective-ccocoaplist

Extract CFKeyedArchiverUID value


I have a plist file in which some "objects" are contained. I can successfully extract a dictionary, but when I try to NSLog an objectForKey I got this kind of log:

<CFKeyedArchiverUID 0x608000228c20 [0x7fff75bddf00]>{value = 815}

how can I extract the value 815?

Maybe it can help knowing that 815 is a reference to a position of an item in the dictionary.

Thanks


Solution

  • Since I can't find a solution I used a trick, I converted the object to a string and using regex I extracted the part between brackets {}. Here's the code, where value is an object in the NSDictionary:

    NSError *error = nil;
    NSRegularExpression *regex = [NSRegularExpression regularExpressionWithPattern:@"\\{(.*?)\\}" options:NSRegularExpressionCaseInsensitive error:&error];
    NSString *result = [[[value objectForKey:@"artist"] description] substringWithRange:[regex rangeOfFirstMatchInString:[[value objectForKey:@"artist"] description] options:0 range:NSMakeRange(0, [[value objectForKey:@"artist"] description].length)]];