0

I have a method and don't use ARC:

-(void)readAppPlist
{
    NSString *plistPath = [self getDataFileDestinationPath];
    NSData *plistXML = [[NSFileManager defaultManager] contentsAtPath:plistPath];
    NSString *errorDesc = nil;
    NSPropertyListFormat format;
    NSMutableDictionary *temp = (NSMutableDictionary *) [NSPropertyListSerialization propertyListFromData:plistXML mutabilityOption:NSPropertyListMutableContainersAndLeaves format:&format errorDescription:&errorDesc];
    if (!temp) {
        NSLog(@"Error reading plist: %@, formatL %d", errorDesc, format);
    }
    items = [[temp objectForKey:@"Items"] mutableCopy];
}

According to the rules of memory management where do I need to release the memory for the variables plistPath, plistXML, errorDesc, temp? Shall I writh another one method, release them here or just put them into the dealloc global method for this class?

meth
  • 1,887
  • 2
  • 18
  • 33
ShurupuS
  • 2,923
  • 2
  • 24
  • 44

1 Answers1

7

Assuming you followed naming conventions correctly (and that is probably a pretty big leap), the answers would be:

plistPath : No
plistXML : No
errorDesc : No
temp : No

The rule is if you alloc copy or retain it, you must release it (new counts as alloc)

borrrden
  • 33,256
  • 8
  • 74
  • 109
  • @borrden So, I don't need to do anything with the variables in this method in the whole application? – ShurupuS Apr 01 '13 at 07:05
  • 1
    I'm not going to answer that (not because I want to be mean, but because I want you to truly understand the last line that I wrote). Instead, look for places where you used any of the words I listed in the last line. I see one occurrence, and that one will need to be released at a later time. – borrrden Apr 01 '13 at 07:07