gpt4 book ai didi

iphone - 具有 +0 保留计数的对象返回给调用者,其中期望 +1(拥有)保留计数

转载 作者:行者123 更新时间:2023-12-03 18:41:29 24 4
gpt4 key购买 nike

我有一组由 www.sudzc.com 创建的类(用于 iPhone/Flex/Javascript 的很棒的 WDSL Web 服务代理创建工具)。

当我运行 CMD+SHIFT+A 来检查内存泄漏时,我收到以下消息:

Object with +0 retain counts returned to caller where a +1 (owning) retain count is expected

这是返回该消息的方法:

// Static method for initializing from a node.
+ (id) newWithNode: (CXMLNode*) node
{
return (id)[[[SoapObject alloc] initWithNode: node] autorelease];
}

我不想使用此代码发送消息,并且随着 Web 服务的更改并且我需要更新代理类,它需要在项目中多次重新生成。

有什么想法吗?

提前致谢。

杰森

最佳答案

分析器正在提示,因为 memory management guide规定...

You “create” an object using a method whose name begins with “alloc” or “new” or contains “copy”'.

Cocoa 和 Objective-C 严重依赖约定,您应该尽一切努力遵循它。打开“将警告视为错误”并解决问题。虽然您可能是现在唯一从事此工作的人,但如果在任何时候其他开发人员要使用您的方法,他们很可能会遵循内存管理准则,并最终过度释放此方法返回的对象(并崩溃)应用程序)。

关于iphone - 具有 +0 保留计数的对象返回给调用者,其中期望 +1(拥有)保留计数,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3553401/

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