xcode 4 垃圾收集已删除?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/5466899/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
xcode 4 garbage collection removed?
提问by jerry
I am learning Xcode and objective c, but the book I am reading is using the older version (3.2) of Xcode. One chapter, which is completely dedicated to memory and leaks, says I need to turn on garbage collection through Project Settings > Build. However, I can't find the garbage collection setting. Has it been removed or am I just missing it?
我正在学习 Xcode 和 Objective c,但我正在阅读的书使用的是旧版本 (3.2) 的 Xcode。一章完全致力于内存和泄漏,说我需要通过项目设置>构建打开垃圾收集。但是,我找不到垃圾收集设置。它被删除了还是我只是想念它?
采纳答案by Lucas Derraugh
Xcode 4 still has Garbage Collection, all you do is go into your project (the top option in the navigation bar with the big xcode project icon). Select your target which should just be the name of your app with the application icon next to it. When you select that, along the top there is a bar with different options, such as summary, info, build settings etc. Hit "Build Settings" and type "garbage" in the search field. Then set garbage collection to required.
Xcode 4 仍然有垃圾收集,你要做的就是进入你的项目(导航栏中的顶部选项,带有大的 xcode 项目图标)。选择你的目标,它应该只是你的应用程序的名称,旁边有应用程序图标。当您选择它时,顶部有一个带有不同选项的栏,例如摘要、信息、构建设置等。点击“构建设置”并在搜索字段中输入“垃圾”。然后将垃圾收集设置为必需。
One very important note about GC is that it is officially deprecated as of Mac OS 10.8, which means you should be transitioning your code to ARC if possible because GC might not be around for much longer.
关于 GC 的一个非常重要的注意事项是它从 Mac OS 10.8 开始正式弃用,这意味着如果可能,您应该将代码转换为 ARC,因为 GC 可能不会存在太久了。
Update: See other answers for enabling GC in current versions of Xcode. As I stated above, you should be transitioning to ARC if you haven't already.
更新:查看在当前版本的 Xcode 中启用 GC 的其他答案。正如我上面所说,如果你还没有过渡到 ARC,你应该过渡到 ARC。
回答by Jonathan Mitchell
As of XCode 4.4 the garbage collection build flag is user defined (see the very end of the build settings list).
从 XCode 4.4 开始,垃圾收集构建标志是用户定义的(参见构建设置列表的最后)。
GCC_ENABLE_OBJC_GC supported
Valid build settings are:
有效的构建设置是:
unsupported: The application cannot load code that requires garbage collection. The loadable bundle cannot be loaded by an application that requires garbage collection.
supported: The application can load code that supports or requires garbage collection. The loadable bundle can be loaded by an application with any level of garbage-collection support.
required: The application can load only code that supports garbage collection. The loadable bundle can be loaded only by an application that supports garbage collection.
不支持:应用程序无法加载需要垃圾回收的代码。需要垃圾收集的应用程序无法加载可加载包。
支持:应用程序可以加载支持或需要垃圾收集的代码。可加载包可以由具有任何级别的垃圾收集支持的应用程序加载。
required:应用程序只能加载支持垃圾收集的代码。可加载包只能由支持垃圾收集的应用程序加载。
回答by bbum
Garbage collection is very much fully supported in Xcode 4. Xcode 4, itself, is a GC'd application.
垃圾收集在 Xcode 4 中得到了非常全面的支持。Xcode 4 本身就是一个 GC 应用程序。
GC is also very much not available in iOS. If you are writing an iPhone/iPad app, you can't use GC.
GC 在 iOS 中也非常不可用。如果您正在编写 iPhone/iPad 应用程序,则不能使用 GC。
回答by dvkempen
As of Xcode 4.3.3 the only setting available for parameter "Objective-C Garbage Collection" under section "Apple LLVM compiler 3.1 - language", Build Settings for your target app = "Unsupported"
从 Xcode 4.3.3 开始,“Apple LLVM 编译器 3.1 - 语言”部分下的参数“Objective-C 垃圾收集”唯一可用的设置,目标应用程序的构建设置 =“不支持”
回答by Kendall Helmstetter Gelner
That's a challenge but you might be able to get it done - here's a starting point to think about in relation to PDF generation:
这是一个挑战,但您可能能够完成它 - 这是与 PDF 生成相关的思考起点:
iOS SDK - Programmatically generate a PDF file
If you can generally follow what is going on there, you might be OK.
如果您通常可以了解那里发生的事情,那么您可能没问题。
回答by Sherm Pendley
Xcode 3.2 is still available for download - in fact, 3.2.6 was released within the past week or two, so it's not exactly "old and busted." :-) Xcode 4's interface is verydifferent, so given your tight schedule and your need to start from square one, you might be better off using 3.2 for now. That will certainly make it far easier to use the book you have.
Xcode 3.2 仍然可以下载——事实上,3.2.6 是在过去一两周内发布的,所以它并不完全是“陈旧的”。:-) Xcode 4 的界面非常不同,因此鉴于您的日程安排很紧并且需要从第一个开始,您现在最好使用 3.2。这肯定会让您更轻松地使用您拥有的书。