gpt4 book ai didi

objective-c - 无法弄清楚这个泄漏

转载 作者:搜寻专家 更新时间:2023-10-30 19:51:33 24 4
gpt4 key购买 nike

SettingsView *settings = [[SettingsView alloc] initWithNibName:@"SettingsView" bundle:[NSBundle mainBundle]];
settings.modalTransitionStyle = UIModalTransitionStyleCoverVertical;
[self.navigationController presentModalViewController:settings animated:YES];
settings = nil;
[settings release];

Instruments 声称以下线路正在泄漏

[self.navigationController presentModalViewController:settings animated:YES];

最佳答案

您需要在将其设置为nil 之前释放settings,而不是之后!

您现在所做的与:

settings = nil;
[nil release];

因此 -release 被发送到 nil,而不是您的 SettingsView 对象。 (向 nil 发送任何消息都是 NOOP)。

关于objective-c - 无法弄清楚这个泄漏,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3311081/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com