objective-c - stringWithCString 中的内存泄漏

标签 objective-c cocoa

我在 stringWithCString 中遇到内存泄漏,有人能在 stringWithCstring 函数中找到内存泄漏吗?

SomeView *detailViewController = [[SomeView alloc] initWithNibName:@"SomeView" bundle:nil];
detailViewController.test = [NSString stringWithCString:"abc" encoding:UTF8_ENCODING];

SomeView 中测试变量的属性是

@property (nonatomic,copy) NSString* test;

我的属性(property)申报正确吗?

最佳答案

您是否在 [SomeView dealloc] 方法中释放字符串,如下所示:

- (void)dealloc
{
    self.test = nil;
    [super dealloc];
}

关于objective-c - stringWithCString 中的内存泄漏,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11482680/

相关文章:

objective-c - NSPredicate 对多对关系的不区分大小写匹配

objective-c - 获取正在运行的应用程序列表(从 Applescript 翻译?)

objective-c - 使用 'variable' 与 '_variable'?

cocoa - OpenStep作为开发环境的最新情况如何?

objective-c - 当代码中有多个图像时,使用 CoreAnimation 时 NSImage 不显示?

objective-c - ios 8 更改呈现/模态视图 Controller 的大小

iphone - 公共(public) header 路径、安装目录、搜索 header 路径和其他噩梦

ios - 如何停止在并发线程中运行的预加载进程?

ios - iPhone map 路线问题

objective-c - UITEXTVIEW:获取最近在uitextview中输入的单词