我在 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/