将 Carbon 代码移植到 Cocoa 的策略

发布于 2024-08-03 19:33:25 字数 347 浏览 4 评论 0原文

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

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

因此,为了将 Carbon 应用程序和工具包引入 64 位,他们的 GUI 部分必须用 Cocoa 和 Objective-C 重新编写,对吧?

如何才能最大限度地减少过渡过程中需要付出的努力?如何最大限度地减少所需的 Objective-C 代码量?

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?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

桃扇骨 2024-08-10 19:33:25

因此,为了将 Carbon 应用程序和工具包引入 64 位,其 GUI 部分必须用 Cocoa 和 Objective-C 重新编写,对吧?

是的。

如何才能最大限度地减少过渡过程中需要付出的努力?如何最大限度地减少所需的 Objective-C 代码量?

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

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

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

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

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

[1]:file:///Developer/Documentation/DocSets/com.apple.ADC_Reference_Library.CoreReference.docset/Contents/Resources/Documents/documentation/Cocoa/index-date0.html(堆栈溢出)不允许我链接文件:URL)

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)

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文