将iOS应用移植到Mac-如何处理内存管理? [英] porting an iOS app to mac -- how to handle memory management?

查看:63
本文介绍了将iOS应用移植到Mac-如何处理内存管理?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的代码中当然包含所有的保留/释放调用. . .是否在不使用垃圾回收的情况下编写Mac应用程序(然后对保留/释放进行处理)会更容易?

My code has all the retain/release calls in it of course . . . is it likely to be easier to write the mac app with garbage collection (and then what do I do about the retains/releases) or without?

无论采用哪种推荐方式,有关相关Xcode设置的任何指针都将有所帮助.谢谢.

Whichever way you recommend, any pointers about relevant Xcode settings would be helpful. Thanks.

推荐答案

出于各种原因,我强烈建议您不要在Mac上使用GC,请坚持使用您以前已经做过的事情.我相信,当您依靠GC管理内存时,您会放弃很多细粒度的控制,而我个人并不喜欢这样做.

I highly recommend that you not use GC on Mac for various reasons, just stick to what you're used to doing already. I believe that when you rely on GC to manage memory, you give up a lot of fine-grain control, which I personally don't enjoy doing.

由于您已经来自像iOS这样的具有引用计数的环境,因此我认为,留在该环境中是明智之举,因为此时您无需付出更多努力.

Since you're already coming from a reference-counted environment like iOS, I think that it would be wise of you to stay in that environment, given that it's not going to take much more effort on your part at this point.

您将需要将视图控制器和基于视图的代码移植到Cocoa,但这不应该太麻烦.您可以放入模型,因为它们没有任何视图依赖性. (当然,前提是您做到了一点点理智).

You will need to port your view controllers and view-based code to Cocoa, but that shouldn't be too much of a hassle. You can drop in your models, because they don't have any view dependencies. (of course assuming you did it with an ounce of sanity).

这篇关于将iOS应用移植到Mac-如何处理内存管理?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆