xcode 4 垃圾收集已删除?
我正在学习 Xcode 和 Objective C,但是我正在阅读的书使用的是旧版本(3.2)的 Xcode。其中一章完全致力于内存和泄漏,说我需要通过“项目设置”>“打开垃圾收集”。建造。但是,我找不到垃圾收集设置。它已被删除还是我只是错过了?
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?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(6)
Xcode 4 仍然有垃圾收集,您所要做的就是进入您的项目(导航栏中的顶部选项,带有大的 xcode 项目图标)。选择您的目标,该目标应该只是您的应用程序的名称,旁边有应用程序图标。当您选择该选项时,顶部会出现一个带有不同选项的栏,例如摘要、信息、构建设置等。点击“构建设置”并在搜索字段中输入“垃圾”。然后将垃圾收集设置为必需。
关于 GC 的一个非常重要的注意事项是,从 Mac OS 10.8 开始,它已被正式弃用,这意味着如果可能的话,您应该将代码转换为 ARC,因为 GC 可能不会存在太久。
更新:请参阅有关在当前版本的 Xcode 中启用 GC 的其他答案。正如我上面所说,如果您还没有迁移到 ARC,那么您应该迁移到 ARC。
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.
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.
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 4.4 开始,垃圾收集构建标志是用户定义的(请参阅构建设置列表的最后部分)。
有效的构建设置为:
不支持:应用程序无法加载需要垃圾回收的代码。需要垃圾收集的应用程序无法加载可加载包。
支持:应用程序可以加载支持或需要垃圾收集的代码。可加载包可以由具有任何级别的垃圾收集支持的应用程序加载。
必需:应用程序只能加载支持垃圾收集的代码。可加载包只能由支持垃圾收集的应用程序加载。
As of XCode 4.4 the garbage collection build flag is user defined (see the very end of the build settings list).
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.
Xcode 4 完全支持垃圾收集。Xcode 4 本身就是一个 GC 应用程序。
GC 在 iOS 中也不太可用。如果您正在编写 iPhone/iPad 应用程序,则无法使用 GC。
Garbage collection is very much fully supported in Xcode 4. Xcode 4, itself, is a GC'd application.
GC is also very much not available in iOS. If you are writing an iPhone/iPad app, you can't use GC.
这是一个挑战,但您也许能够完成它 - 这是考虑与 PDF 生成相关的起点:
iOS SDK - 以编程方式生成 PDF 文件
如果您可以大致了解那里发生的事情,那么您可能没问题。
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:
iOS SDK - Programmatically generate a PDF file
If you can generally follow what is going on there, you might be OK.
Xcode 3.2 仍然可供下载 - 事实上,3.2.6 是在过去一两周内发布的,因此它并不完全是“过时且已失效”。 :-) Xcode 4 的界面非常不同,因此考虑到您的日程安排很紧并且需要从头开始,您现在最好使用 3.2。这肯定会让您更轻松地使用这本书。
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 very different, 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 4.3.3 开始,“Apple LLVM 编译器 3.1 - 语言”部分下的参数“Objective-C Garbage Collection”唯一可用的设置,目标应用程序的构建设置 =“不支持”
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"