+(NSMutableDictionary*)getList:(NSString *)key
{
......
NSMutableDictionary *dict=[[NSMutableDictionary alloc] initWithContentsOfFile:key];
return dict;
}
调用时
NSMutableDictionary *obj = [self getList:key];
[obj.release];Instruments中偶尔提示内存泄漏 指向
NSMutableDictionary *dict=[[NSMutableDictionary alloc] initWithContentsOfFile:key];请教问题出在哪里?
{
......
NSMutableDictionary *dict=[[NSMutableDictionary alloc] initWithContentsOfFile:key];
return dict;
}
调用时
NSMutableDictionary *obj = [self getList:key];
[obj.release];Instruments中偶尔提示内存泄漏 指向
NSMutableDictionary *dict=[[NSMutableDictionary alloc] initWithContentsOfFile:key];请教问题出在哪里?
解决方案 »
- 新人求助:UINavigationBar 的backbarButtonItem问题。
- iphone的文本编辑器是用什么做的
- 如何将库编译为兼容i386???
- 请教下,投入2w元,能开发一个应用吗?
- 如何在iphone safari定位?
- Iphone首选相如何做国际化
- 新手关于的 subview 一个问题
- UIAlertView UITapGestureRecognizer 点击窗口之外区域关闭
- 同时执行多个线程,当其中一个线程执行完的时候,终结其他线程,怎么做????
- app的字体为什么就是要比其他的app大一号啊
- iPhone SDK开发:禁止UIWebView的bounces
- 可以取到手指在屏幕的覆盖范围吗?
{
//使用autorelease
[NSMutableDictionary *dict=[[NSMutableDictionary alloc] initWithContentsOfFile:key] autorelease];
return dict;
}
{
//使用autorelease
NSMutableDictionary *dict=[[[NSMutableDictionary alloc] initWithContentsOfFile:key] autorelease];
return dict;
}
[obj.release];
是不对的,肯定报错的
因为(getList:)是+2,代码在释放池中的话,可以返回 autorelease
或者调用后自动释放
NSMutableDictionary *obj = [类 getList:key];
这里如果是在普通函数中的话,大可不用管。因为函数结束后,所有的引用地址会自动释放。 *obj是指针,没有alloc。
我现在需要obj持久保持的
在该方法内,记得obj release 一次。dealloc 中,也要release 一次
{
......
NSMutableDictionary *dict=[[NSMutableDictionary alloc] initWithContentsOfFile:key];
return [dict autorelease];
}记得外部不需要release了。