Question about memory usage

Posted by sudo rm -rf on Stack Overflow See other posts from Stack Overflow or by sudo rm -rf
Published on 2011-01-10T03:51:16Z Indexed on 2011/01/10 3:53 UTC
Read the original article Hit count: 193

Hi there.

I have the following method:

+(NSMutableDictionary *)getTime:(float)lat :(float)lon {
    NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];

    NSMutableDictionary *dictionary = [[NSMutableDictionary alloc] init];
    [dictionary setObject:hour forKey:@"hour"];
    [dictionary setObject:minute forKey:@"minute"];
    [dictionary setObject:ampm forKey:@"ampm"];

    return dictionary;
}

A lot of the method is chopped off, so I think I need the pool for some other stuff in the method. Here's my question. I know that I need to release the following objects:

[dictionary release];
[pool release];

However, I can't release the dictionary before I return it, but as soon as I return it the rest of the method isn't performed. What should I do?

© Stack Overflow or respective owner

Related posts about iphone

Related posts about objective-c