[翻訳]Cocoaの勉強方法

7075 ワード

[翻译] 如何学习Cocoa
[文章の元の住所]http://funwithobjc.tumblr.com/人の翻訳、どうしても间违いがあることができて、各位の见官は大目に见て、翻訳は最后に私は文章の部分の地方で注釈をプラスして、そして需要によって文章の内容を増减して、ここで原作者に対して勤勉に働いて感谢します
How to learn Cocoa
This is something any experienced Cocoa developer has been asked at least half a dozen times:
"What’s the best way to learn Objective-C/Cocoa?"
I have two answers to this question:
  • Be curious
  • Don’t be satisfied

  • Be Curious
    Curiosity is the heart of learning anything. If you can cultivate a deep curiosity about the Objective-C language and the Cocoa frameworks, then I guarantee that you will have absolutely no problem learning them. I’m not talking about the “oh, wouldn’t it be nice to know how to write iOS apps” kind of curiosity. I’m talking about the “why does the  @  sign go there? What’s up with these asterisks all over the place? Why are things done in this order instead of that order” kind of curiosity. Gaining this level of curiosity can be very difficult, especially at first. But without it, you’ll never really understand how everything is working together.
    If you’re familiar with an sort of object-oriented programming language, then Objective-C, as a language, shouldn’t be that hard to pick up. Just use get used to the square brackets, and things will look pretty familiar. Learning the frameworks, on the other hand, will take a lifetime. The Cocoa Frameworks (Foundation, AppKit/UIKit, CoreData, CoreFoundation, MapKit, QuickLook, MediaAccess, CoreLocation, etc) are enormously broad. The  Foundation framework  itself is composed of 173 public classes and 31 protocols. That’s a lot of pre-built code, and that’s just one framework out of a couple dozen! There are some classes you will come to know very intimately ( NSStringNSArray , NSDictionary ), but even they will surprise you every now and then. Plus, Apple actively develops these frameworks; they’re being improved and optimized and expanded all the time. There will always be more to learn.
    Along with the capabilities of the classes, there are  patterns to learn . Design patterns describe how classes interact with each other. Some of the first ones you’ll encounter are  Model View ControllerDelegation , and  Class Clusters . There are many others, and they’re in there for a very good reason. As you come across them, take the time to understand why they’re there.
    Do the same with the classes in the frameworks. Explore them. Play with them. Abuse them. Ask yourself:
  • What problem does this solve?
  • How does it solve the problem?
  • Can you use these abilities for anything else?
  • How would you implement this class if you had to? (And then go do it!)

  • Be curious.
    Don’t Be Satisfied
    As you learn Cocoa, the code you write will be terrible. Understand that. But don’t accept it. There is always a different way you could do something, and quite often one of those different ways is a better way. Always seek out opportunities to improve your code and to find different and better ways to organize it. Sometimes this will mean rewriting things half a dozen times. But you know what? That’s OK! All developers experience this. If you can learn to not be satisfied with your code, you’ll quickly learn how to iterate over it and make improvements here, tweak some stuff there, maybe rip out some layer of control and totally reorganize it… This is what programming is all about. Don’t be satisfied with how your code looks. Strive to make it a work of art and a thing of beauty.
    Final Thoughts
    So there you have it! These are my recommendations for how to learn Cocoa. They have served me well, and I think they pretty much summarize what I’ve observed about experienced developers.
    Oh, and by the way…
  • Know what a pointer is.
  • Memorize the memory management rules.
  • Never invoke  -retainCount .

  • Welcome to Cocoa.
     
    Cocoaの勉強方法
    これは、牛が追い詰めたCocoa開発者が何度も質問された質問です.
    「Object-C/Cocoaを学ぶ最善の方法は何ですか?」
    この問題について、私は2つの提案があります.
    1.好奇心を保つ
    2.簡単に満足しない
    好奇心を保つ
    何事も好奇心を学ぶのが一番だ.もしあなたがObjective-CとCocoaのフレームワークに深い興味を持っていれば、私はあなたがそれを学ぶのに絶対に問題がないと確信しています.「IOSのプログラムを書くのはかっこいいのではないでしょうか」とは言いません.などと、私は「なぜ表記@がここに置かれているのか、なぜ星号がそこに置かれているのか、なぜそうしなければならないのか」というように、この程度の好奇心を持つのは難しいです.特に最初は.しかし、好奇心がなければ、それらがどのように機能しているかは本当に分かりません.
    オブジェクト向けのプログラミング言語を熟知している場合は、Objective-Cは、新しい言語として学ぶのは難しくありません.角カッコの呼び出し関数の方法を熟知するだけで、彼らは非常に似ているように見えます.これらの枠組みを学ぶには、ある角度から言えば、長い時間がかかる.このCocoaのいくつかのフレームワーク(Foundation,AppKit/UIKEt,CoreData,CoreFoundation,MapKit,QuickLook,MediaAccess,CoreLocationなど)の内容は非常に多い.Foundationフレームワーク自体には173クラスと31プロトコルが含まれている.それらはやはり予めコンパイルされたコードで、その卵の中の1枚だけです--!いくつかのクラス(NSString、NSArray、NSDictionary)は、今驚くかもしれませんが、将来的にはよく知っています.さらに、アップルはこれらのフレームワークの開発で活躍しており、これらのフレームワークはずっと完備している.拡張と最適化が必要なので、ずっと勉強する必要があります.
    この無数の類に直面して、1種の学習モードが存在している.設計モードは、クラスとクラスとの間にどのように関連するかを記述する.あなたが初めて出会うデザインモデルにはMVCがあります.エージェントとクラスクラスタ(私はどのように翻訳するか分からないので、接触したことがありません).実際には他にも多くのデザインモデルがあります.存在するのは合理的です.それに出会ったとき、もっと時間をかけて熟知しましょう.
    フレームワークの中のクラスに対して同じことをして、それらを探求して、それらを使って、それらを虐げて、あなた自身に聞いてみてください.
    このクラスはどんな問題を解決できますか.
    どうやってこの問題を解決しましたか?
    他に何かしてもらえますか?
    クラスを書き直さなければならない場合、どのようにしてこのクラスを実現しますか?(思いついたらやろう)
    好奇心を保つ
    簡単に満たさないで
    Cocoaを勉強すると、最初はコードが腐ってしまいます.この道理を理解しなければなりませんが、それに満足しないでください.他の方法を試してみることができ、より良い方法を見つけることができます.あなたのコードを最適化する機会を探して、異なる方法ともっと良い方法を探してそれらを書き直します.時々、これは何度も書き直すことを意味しますが、知っていますか?そうすべきだろう.すべての開発者はこの過程を経験します.もしあなたが簡単に満足しないことをマスターしたら、あなたはすぐに何度もそれを書き直して進歩したことを認識して、ここで全力を尽くして、秘密を一つ一つ引き裂いて最終的に完全に理解することができるかもしれません...プログラミングはこのことです.自分で書いたコードに満足しないで、できるだけ彼を芸術としてして、その美感を体得してください.
    最後の思考
    これだけだ!私がCocoaを勉強することについてのアドバイスです.それらは私にとても役に立ち、これが私がまとめた牛が開発者を追い詰めた経験だと思います.
    ああ、ついでに...
    1.ポインタとは何かを知る
    2.メモリ管理規則を記憶する
    3.判断を決して試みないretainCount ( )