简体   繁体   English

Objective-C或Cocoa First

[英]Objective-C or Cocoa First

I am new to Mac/iOS development. 我是Mac / iOS开发的新手。 I am coming over from C# .net. 我是从C#.net过来的。 My question is should I read on Objective-C first or Cocoa? 我的问题是我应该首先阅读Objective-C还是Cocoa? I don't want to buy two books and start reading one and find out I should have only got one book and read it. 我不想买两本书然后开始阅读一本,然后发现我应该只买一本书并阅读。 Thanks Curtis 谢谢柯蒂斯

看看如何使用Objective-C构建Cocoa框架,学习语言是合乎逻辑的第一步。

You don't need to become fluent in the language, to the point of exchanging implementations and dispatching blocks like nobody's business, all before you learn the frameworks. 在学习框架之前,您不需要熟练掌握语言,交换实现和调度块,如无人的业务。 Indeed, such an undertaking would be folly. 实际上,这样的事业将是愚蠢的。

At the same time, you can't learn Cocoa without a firm grasp of OOP, dynamic dispatch (messaging), MVC, and other important concepts. 同时,如果没有对OOP,动态调度(消息传递),MV​​C和其他重要概念的牢固掌握,您将无法学习Cocoa。 Some of these underlie Objective-C, some are part of Objective-C, and some are separate from Objective-C. 其中一些是Objective-C的基础,一些是Objective-C的一部分,一些是与Objective-C分开的。

I say start learning those concepts, including the basic portions of the language, and then pick up the framework before you get too far into it. 我说开始学习这些概念,包括语言的基本部分,然后在你进入太远之前选择框架。 Like Regexident said in their comment on one of the other answers, you pretty much can't practice Objective-C without using Cocoa anyway, so it won't be long before you need to start into the framework to in order to practice the language—at which point you'll be practicing with both. 就像Regexident在评论其他一个答案时说的那样,你几乎不能在不使用Cocoa的情况下练习Objective-C,所以不久之后你需要开始进入框架才能练习语言 - 你要用两者练习哪一点。

Relevant Apple documentation: 相关的Apple文档:

If you don't already know C, start there. 如果您还不知道C,请从那里开始。 As with Objective-C, you don't need to become a full-blown C guru, but you do need to understand pointers, declarations vs. statements, how function calls work, the differences between the primitive types, and other basic concepts. 与Objective-C一样,您不需要成为一个成熟的C大师,但您需要了解指针,声明与语句,函数调用如何工作,基元类型之间的差异以及其他基本概念。

Objective-C is just a superset of C. All the Cocoa books that I've seen introduce Objective-C in the first part and then go on to describe how to use the frameworks. Objective-C只是C的超集。我见过的所有Cocoa书籍都在第一部分介绍了Objective-C,然后继续描述如何使用框架。 I'd recommend just getting a Cocoa book, just leaf through it and make sure the Objective-C primer in it is meaty enough for you. 我建议你拿一本可可书,然后翻阅它并确保其中的Objective-C底漆对你来说足够多。

I believe there is a lot of good information in the various answers here (especially @Peter Hosey's), but I do want to make sure we're not confusing the OP. 我相信这里的各种答案中都有很多好的信息(特别是@Peter Hosey的),但我确实想确保我们不要混淆OP。

You can't practically learn ObjC without learning Cocoa today. 如果不学习Cocoa,你几乎无法学习ObjC。 It's like learning C# without learning .NET. 这就像学习C#而不学习.NET。 You absolutely should focus very early on the patterns and underlying concepts of Cocoa (like MVC, as PH notes). 你绝对应该尽早关注Cocoa的模式和基本概念(如MVC,如PH注释)。 But you'll get that best by working through things that teach you practical iOS or Mac development techniques rather than working through something that tries to provide a more "pure ObjC" experience such as writing command-line apps (though even Foundation is part of Cocoa, so even then you can't escape it). 但是你会通过教你实用的iOS或Mac开发技术而不是通过尝试提供更“纯粹的ObjC”体验的东西来编写命令行应用程序(尽管甚至基金会是可可,所以即便如此你也无法摆脱它)。

The key lesson here is that I recommend new students focus on resources that teach them the whole process they need to develop for iOS or OS X. It's worth learning Xcode, ObjC, and Cocoa(Touch) together, along with MVC, target/selector, and the other critical patterns, rather than trying to take them one at a time. 这里的关键教训是,我建议新学生专注于教授他们为iOS或OS X开发所需的整个过程的资源。值得学习Xcode,ObjC和Cocoa(Touch)以及MVC,目标/选择器和其他关键模式,而不是一次尝试一个。

PH is absolutely correct that you don't need to learn all of ObjC in one go. PH绝对正确,您无需一次性学习所有 ObjC。 You can do a lot of development and never use blocks or KVO for instance. 你可以做很多开发,从不使用块或KVO。 (That may change in future versions of iOS, but it's still true today.) (这可能会在iOS的未来版本中发生变化,但今天仍然如此。)

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

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