Summary
This hour provides an introduction to Objective-C and its concepts, as well as a general comparison to other object-oriented languages you might know. The biggest differences from other object-oriented languages are its messaging syntax (rather than function calling syntax), the ability to extend code in ways other than subclassing (protocols, delegates, and categories), and its somewhat more rigorous enforcement of basic object-oriented design principles when compared to languages such as C++ (this last point remains a topic of much discussion and dissension).
You have seen some examples of Objective-C code at work, and you will see more—and write more—throughout this book. For some people, the syntax and nomenclature is daunting with all its square brackets. Have no fear; if you start to use it, you will soon become accustomed to it. Furthermore, that syntax helps you access some of the powerful features of Objective-C that have no direct parallels in other programming languages.
Q&A
- Q. Where is the best place to start learning about model/view/controller?
- A.Start with controllers and, in particular, start with some of the view controllers such as the ones described in Part IV. The basics of both the view and model components of MVC are quite simple—one is your data and the other is your interface. The controller is pretty much where all the programming you are used to takes place.
- Q. Are there naming conventions for methods and instances?
- A.Naming conventions for instance variables are usually dependent on the project or developer. Inside the frameworks, you will find a number of standard types of methods. These are typically implemented in subclasses of the major framework classes. They have names such as viewWillAppear and viewDidAppear so that you can insert your code at the right place. The documentation on developer.apple.com helps you to understand which parts of the creation of objects such as views (and the corresponding destruction) are done in which step.