简体   繁体   English

将碳代码移植到Cocoa的策略

[英]Strategies for porting Carbon code to Cocoa

I'm looking for strategies and articles on making Carbon code 64-bit ready. 我正在寻找关于使碳码64位准备就绪的策略和文章。

Carbon for 64-bit does not and will not exist. 64位的碳不会也不会存在。 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? 因此,为了将Carbon应用程序和工具包带到64位,他们的GUI部分将不得不在Cocoa和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? 如何最小化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? 因此,为了将Carbon应用程序和工具包带到64位,他们的GUI部分将不得不在Cocoa和Objective-C中重写,对吗?

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? 如何最小化Objective-C代码所需的数量?

  1. Learn Cocoa. 学习可可。 Read The Objective-C Programming Language and the Cocoa Fundamentals Guide . 阅读Objective-C编程语言Cocoa基础指南 Become familiar with MVC, KVC, and Objective-C. 熟悉MVC,KVC和Objective-C。 Bookmark the Foundation and AppKit framework references. FoundationAppKit框架引用添加书签。 Learn to love Interface Builder, for it is your friend (moreso in Cocoa than it ever was in Carbon). 学会喜欢Interface Builder,因为它是你的朋友(在Cocoa中比在Carbon中更多)。
  2. Get good at Cocoa. 擅长可可。 Read more Guides (if you're still on Leopard, use [1] instead). 阅读更多指南 (如果你还在Leopard上,请改用[1])。 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. 如果可以的话,可以根据BSD许可证将它们丢弃,然后编写可重复使用的源代码并将其丢弃。 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 Porting Guide ,然后移植您的应用程序。

I came from Carbon myself. 我自己来自Carbon。 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. 至于你的应用程序,你可能需要做很多手术,因为Carbon没有像Cocoa那样强迫你保持UI和逻辑分离。 Cocoa enforces MVC; Cocoa执行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. 这让Cocoa听起来更像是工作,但事实并非如此。 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. 移植很难(不可避免),但除此之外,Cocoa恰恰相反:编写(和阅读!)Cocoa应用程序比编写(和阅读)Carbon应用程序容易得多。 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 . 哦,很多人会推荐Aaron Hillegass的Mac OS X Cocoa ProgrammingStephen Kochan 编写的Objective-C 2.0中的一个或两个。 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) [1]: file:///Developer/Documentation/DocSets/com.apple.ADC_Reference_Library.CoreReference.docset/Contents/Resources/Documents/documentation/Cocoa/index-date0.html (Stack Overflow不会让我链接文件:网址)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM