Release Quickie

Posted by Meltemi on Stack Overflow See other posts from Stack Overflow or by Meltemi
Published on 2010-04-22T22:57:05Z Indexed on 2010/04/22 23:03 UTC
Read the original article Hit count: 268

How to succinctly handle this situation. I'm not properly releasing contactDictionary in the if statement...

    NSNumber *pIDAsNumber;
     ...        
    NSMutableDictionary *contactDictionary = [NSMutableDictionary dictionaryWithDictionary:[defaults dictionaryForKey:kContactDictionary]];
    if (!contactDictionary) {
            contactDictionary = [[NSMutableDictionary alloc] initWithCapacity:1];
    }
    [contactDictionary setObject:pIDAsNumber forKey:[myClass.personIDAsNumber stringValue]];
    [defaults setObject:contactDictionary forKey:kContactDictionary];

© Stack Overflow or respective owner

Related posts about retain

Related posts about release