将单个文件转换为arc?(Converting individual files to arc?)

编程入门 行业动态 更新时间:2024-10-16 16:11:56
将单个文件转换为arc?(Converting individual files to arc?)

我已经看到很多关于将整个项目转换为弧然后使用标志告诉Xcode哪些不能转换的信息。

将单个文件转换为arc的方法如何? 我试过了,运行良好。 我可以这样做吗? 我有点担心,因为如果我在这里和那里转换东西,整个项目不会转换为弧,它们会导致内存泄漏。

I've seen lots of info about converting a whole project to arc and then using flags to tell Xcode which ones not to convert.

What about converting only individual files to arc? I tried it, and it runs fine. Can I do that? I'm kind of worried that since the whole project isn't converted to arc if I convert things here and there they'll cause memory leaks.

最满意答案

是的你可以。 但是,您需要告诉编译器哪些文件不是ARC。 这可以在您的项目设置中执行。 转到your project > Select the target of the app in question > Build Phases 。 现在拖放“Compile Sources”并选择你不想用ARC编译的文件,按下ENTER键,会出现一个小小的弹出框。 在这里你可以写-fno-objc-arc 。 按Done ,你就完成了。

在编译时,它会尝试将自动引用计数添加到没有-fno-objc-arc标志的文件。 使用非弧库时非常有用,如ASIHTTPRequest或MBProgressHud(及其他)。

Yes, you can. However, you need to tell the compiler which files are not ARC. This you can do in your project settings. Go to your project > Select the target of the app in question > Build Phases. Now drop down the "Compile Sources" and select the files you wish not to compile with ARC, press ENTER and a little popup box will appear. Here you can write -fno-objc-arc. Press Done and you are done.

When compiling, it will try to add automated reference counting to the files which do not have the -fno-objc-arc flag. Very usefull when using non-arc libs such as ASIHTTPRequest or MBProgressHud (and others).

更多推荐

本文发布于:2023-04-27 13:10:00,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1326416.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:转换为   文件   arc   files   individual

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!