关于 Xcode 4.3 中的自动发布

发布于 2024-12-26 00:02:04 字数 531 浏览 4 评论 0原文

嗨,我是目标 C 的新手。 在旧版本的 Xcode 中,当我们创建新项目时,IDE 会生成如下所示的 NSAutoreleasePool 对象,以允许自动释放对象

int main (int argc, char *argv[]) {
        NSAutoreleasePool * pool = [[NSAutoreleasePool alloc] init];

        [pool drain]; 
        return 0; }

。但是在 Xcode 4.3 中,IDE 会生成以下代码

int main (int argc, const char * argv[])

{

    @autoreleasepool {
          //insert code

    }
    return 0; 
}

。在旧版本中,我可以手动释放对象。 。使用新的 Xcode 4.3,当我尝试释放对象但释放功能被划掉时......为什么......?

谢谢。

Hi I'm new to objective C.
In the old version of Xcode, when we create new project the IDE generate NSAutoreleasePool object like below to allow auto release an object

int main (int argc, char *argv[]) {
        NSAutoreleasePool * pool = [[NSAutoreleasePool alloc] init];

        [pool drain]; 
        return 0; }

However in the Xcode 4.3, the IDE generate the below code

int main (int argc, const char * argv[])

{

    @autoreleasepool {
          //insert code

    }
    return 0; 
}

With the older version .. i could manually release the object .. With the new Xcode 4.3 when i tried release the object but the release function is crossed out ... Why is that...?

Thank you.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

删除→记忆 2025-01-02 00:02:04

新项目默认启用 ARC(自动引用计数)。在 ARC 中,禁止对 objc 对象进行引用计数操作。

新项目序列中应该有一个选项来使用手动引用计数或 GC。

New projects have ARC (Automatic Reference Counting) enabled by default. In ARC, reference count operations on objc objects are forbidden.

There should be an option in the New Project sequence to use manual reference counting or GC.

于我来说 2025-01-02 00:02:04

您的项目中启用了 ARC(自动引用计数)。在 ARC 中,不允许对对象进行引用计数操作(例如释放)。通过“release”的红线仅表示该方法已被弃用或不再需要。系统会为你释放一切。

ARC (Automatic Reference Counting) is enables in your project. In ARC, reference count operations (ex. release) on objects are not allowed. The red line through "release" simply means that the method is deprecated, or no longer needed. The system will release everything for you.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文