将碳代码移植到Cocoa的策略 [英] Strategies for porting Carbon code to Cocoa

查看:235
本文介绍了将碳代码移植到Cocoa的策略的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在寻找有关使碳代码64位准备就绪的策略和文章。



将不存在。这几乎是一个死胡同



因此,为了将Carbon应用程序和工具包带到64位,他们的GUI部分必须在Cocoa和Objective-C中重写, p>

如何减少我在转换过程中所付出的努力?如何最小化所需的Objective-C代码的数量?

解决方案


Carbon应用程序和64位的工具包的GUI部分必须在Cocoa和Objective-C中重写。



如何最大限度地减少我在转换中所付出的努力?如何最小化所需的Objective-C代码量?





  1. 请阅读 Objective-C编程语言 Cocoa基础指南。熟悉MVC,KVC和Objective-C。将基金会 AppKit 框架引用。学习喜欢Interface Builder,因为它是你的朋友(Cocoa的moreso比Carbon)。

  2. 善用Cocoa。阅读更多指南(如果你还在Leopard,请改用[1])。编写多少一次性的应用程序,甚至真实的应用程序,你可以在任何时间你可以得到。如果可以,请根据BSD许可授予他们,并编写可重复使用的源代码,并放弃。人们会发现bug,有些会告诉你他们,有些会提交补丁。

  3. 阅读 Carbon Porting Guide ,然后移植您的应用程式。

我来自Carbon。它完全不同 - 你可能会开始新鲜,忽视你以前的碳的经验,也许你不会做一些早期的错误,我做了(像跳过模型层)。



至于你的应用程序,你可能有很多手术要做,因为Carbon不强迫你保持UI和逻辑分开像Cocoa一样。 Cocoa强制执行MVC;如果你不遵守它,你通过重新发明车轮,制造和纠正错误来支付价格。



这使Cocoa听起来更像工作,但不是。移植是很难的(不可避免的),但除此之外,Cocoa恰恰相反:写Cocoa应用程序比编写(和阅读)Carbon应用程序更容易。一旦移植结束,您将很高兴您切换。



哦,很多人会推荐一个或两个 Mac OS X的Cocoa编程由Aaron Hillegass 在Objective-C 2.0中由Stephen Kochan编程。我有第一本书,已经读了一些,但那是在我已经学会了可可,所以我不能认真推荐它;说的,这不坏,我不认为你会错了阅读它。我还没有看到第二本书,所以我不会说任何关于它的质量。



[1]: file:/// Developer / Documentation / DocSets / com.apple.ADC_Reference_Library.CoreReference.docset / Contents / Resources / Documents / documentation / Cocoa / index-date0.html (Stack Overflow不会让我链接文件:URLs )


I'm looking for strategies and articles on making Carbon code 64-bit ready.

Carbon for 64-bit does not and will not exist. It's pretty much a dead end.

So in order to bring Carbon application and toolkits to 64-bit their GUI part will have to be re-written in Cocoa and Objective-C, right?

How can I minimize the effort I have to put into the transition? How can I minimize the amount of needed Objective-C code?

解决方案

So in order to bring Carbon application and toolkits to 64-bit their GUI part will have to be re-written in Cocoa and Objective-C, right?

Yup.

How can I minimize the effort I have to put into the transition? How can I minimize the amount of needed Objective-C code?

  1. Learn Cocoa. Read The Objective-C Programming Language and the Cocoa Fundamentals Guide. Become familiar with MVC, KVC, and Objective-C. Bookmark the Foundation and AppKit framework references. Learn to love Interface Builder, for it is your friend (moreso in Cocoa than it ever was in Carbon).
  2. Get good at Cocoa. Read more Guides (if you're still on Leopard, use [1] instead). Write as many throwaway apps and even real apps as you can get away with in whatever time you have available. If you can, give them away under a BSD license, and write reusable source code and give that away, too. People will find bugs and some will tell you about them, and some will submit patches. Get to be able to write a complete app with a model layer, no more than two controllers, and at least one custom view or cell in a day.
  3. Read the Carbon Porting Guide, then port your app.

I came from Carbon myself. It's completely different—you may as well start fresh, ignoring your previous Carbon experience, and maybe you won't make some of the early mistakes I did (like skipping the model layer).

As for your app, you probably have a lot of surgery to do, as Carbon did not force you to keep UI and logic separate like Cocoa does. Cocoa enforces MVC; if you don't adhere to it, you pay the price by reinventing wheels and making and correcting mistakes.

That makes Cocoa sound like more work, but it's not. Porting is hard (inevitably), but otherwise, Cocoa is quite the opposite: Writing (and reading!) a Cocoa app is much easier than writing (and reading) a Carbon app. Once the porting is over, you'll be glad you switched.

Oh, and many people will recommend one or both of Cocoa Programming for Mac OS X by Aaron Hillegass and Programming in Objective-C 2.0 by Stephen Kochan. I have the first book, and have read some of it, but that was after I had already learned Cocoa, so I can't earnestly recommend it; that said, it is not bad, and I don't think you'd do wrong to read it. I have not even seen the second book, so I won't say anything about its quality.

[1]: file:///Developer/Documentation/DocSets/com.apple.ADC_Reference_Library.CoreReference.docset/Contents/Resources/Documents/documentation/Cocoa/index-date0.html (Stack Overflow won't let me link file: URLs)

这篇关于将碳代码移植到Cocoa的策略的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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