gpt4 book ai didi

objective-c - GNUStep NSAutoreleasePool 不兼容

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

根据 another Stack Overflow post drain 消息是一个仅限 Apple 的调用:

NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
NSLog (@"Hello");
[pool drain];
return 0;

drain 替换为 release 是否安全?我正在尝试移植一个 Objective-C 应用程序以在 Linux(目前是 Ubuntu)上运行。我应该在开始之前就放弃吗? (我已经在尝试让 NSURLConnection 工作时遇到问题)

最佳答案

来自 Apple 的 drain 文档:

[...] this method behaves the same as release. [...]

因此,清空自动释放池意味着不可避免地要释放它。在我看来,Apple 应该弃用 drain,因为它只会造成困惑。

但是:

Special Considerations:
In a garbage-collected environment, release is a no-op, so unless you do not want to give the collector a hint it is important to use drain in any code that may be compiled for a garbage-collected environment.

关于objective-c - GNUStep NSAutoreleasePool 不兼容,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/1483368/

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