0
我有以下方法:问题有关内存使用
+(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;
}
很多方法被砍掉,所以我想我需要在方法的一些其他的东西游泳池。这是我的问题。我知道,我需要释放下列对象:
[dictionary release];
[pool release];
但是,我不能释放字典才返回它,但只要我回到它不执行该方法的其余部分。我该怎么办?
Objective-C中的方法*除非通过引用返回多个值,否则不会*命名为`get *`。你也不会看到这样的冒号。将你的方法命名为`timeForLatitude:longitude:`。 – bbum 2011-01-10 05:23:32
@bbum谢谢你的风格建议! – 2011-01-10 15:51:41