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

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

问题描述

我正在寻找有关使 Carbon 代码支持 64 位的策略和文章.

用于 64 位的 Carbon 不存在,也不会存在.这几乎是一个死胡同.

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

所以为了将 Carbon 应用程序和工具包带到 64 位,他们的 GUI 部分必须用 Cocoa 和 Objective-C 重写,对吗?

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?

我怎样才能最大限度地减少我必须投入到过渡中的努力?如何最大限度地减少所需的 Objective-C 代码量?

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

推荐答案

所以为了将 Carbon 应用程序和工具包带到 64 位,他们的 GUI 部分必须用 Cocoa 和 Objective-C 重写,对吗?

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?

是的.

我怎样才能最大限度地减少我必须投入到过渡中的努力?如何最大限度地减少所需的 Objective-C 代码量?

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. 学习可可.阅读Objective-C 编程语言可可基础指南.熟悉 MVC、KVC 和 Objective-C.为 FoundationAppKit 框架参考.学会喜欢 Interface Builder,因为它是您的朋友(在 Cocoa 中比在 Carbon 中更是如此).
  2. 擅长可可.阅读更多指南(如果您仍在使用 Leopard,请改用 [1]).编写尽可能多的一次性应用程序,甚至是真正的应用程序,您可以在任何可用的时间内完成.如果可以,请在 BSD 许可下将它们分发出去,并编写可重用的源代码并将其分发出去.人们会发现错误,有些人会告诉你它们,有些人会提交补丁.能够在一天内编写一个包含模型层、不超过两个控制器和至少一个自定义视图或单元格的完整应用.
  3. 阅读碳移植指南,然后移植您的应用.
  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.

我自己来自 Carbon.这是完全不同的——你不妨重新开始,忽略你之前的 Carbon 经验,也许你不会犯我之前犯过的一些错误(比如跳过模型层).

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).

至于您的应用程序,您可能有很多手术要做,因为 Carbon 并没有像 Cocoa 那样强迫您将 UI 和逻辑分开.Cocoa 强制执行 MVC;如果你不遵守它,你就会付出代价,重新发明轮子,犯错并纠正错误.

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.

这让 Cocoa 听起来更像是工作,但事实并非如此.移植很难(不可避免),但除此之外,Cocoa 恰恰相反:编写(和阅读!)Cocoa 应用程序比编写(和阅读)Carbon 应用程序容易得多.移植结束后,您会很高兴自己切换了.

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.

哦,很多人会推荐 Mac OS X 的 Cocoa 编程作者:Aaron Hillegass在 Objective-C 2.0 中编程,Stephen Kochan.我有第一本书,也读过一些,但那是在我已经学过Cocoa之后,所以我不能认真推荐它;也就是说,这还不错,我认为您阅读它不会做错.我什至没有看过第二本书,所以我不会说它的质量.

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(堆栈溢出不会让我链接文件:网址)

[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)

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

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