Iphone 如何释放返回的对象?
我在一个类中编写了此方法:Iphone 如何释放返回的对象?,iphone,objective-c,ios,ios4,nsmutabledictionary,Iphone,Objective C,Ios,Ios4,Nsmutabledictionary,我在一个类中编写了此方法: - (NSMutableDictionary *)fetch { NSMutableDictionary *ret = [[NSMutableDictionary alloc] init]; // filling ret with some data here return ret; } 不发布就返回此NSMUtableDictionary对象的方法正确吗 谢谢你的帮助 Stephane执行以下操作: - (NSMutableDictionary
- (NSMutableDictionary *)fetch {
NSMutableDictionary *ret = [[NSMutableDictionary alloc] init];
// filling ret with some data here
return ret;
}
不发布就返回此NSMUtableDictionary对象的方法正确吗
谢谢你的帮助
Stephane执行以下操作:
- (NSMutableDictionary *)fetch {
NSMutableDictionary *ret = [[NSMutableDictionary alloc] init];
// filling ret with some data here
return [ret autorelease];
}
要了解有关自动释放的更多信息,请阅读。执行以下操作:
- (NSMutableDictionary *)fetch {
NSMutableDictionary *ret = [[NSMutableDictionary alloc] init];
// filling ret with some data here
return [ret autorelease];
}
要了解有关自动释放的更多信息,请阅读。像这样使用
- (NSMutableDictionary *)fetch {
NSMutableDictionary *ret = [[NSMutableDictionary alloc] init];
// filling ret with some data here
return [ret autorelease];
}
像这样使用
- (NSMutableDictionary *)fetch {
NSMutableDictionary *ret = [[NSMutableDictionary alloc] init];
// filling ret with some data here
return [ret autorelease];
}
自动释放将对象放入自动释放池,并在返回后调用释放。
自动释放将对象放入自动释放池,并在返回后调用释放。小提示:下一个iOS版本具有功能,因此您不必再自己管理内存。;-)只需使用
[NSMutableDictionary]
即可,因为它已经自动删除。小提示:下一个iOS版本具有一些功能,因此您不必再自己管理内存了。;-)只需使用[NSMutableDictionary]
即可,因为它已自动删除。