Learning iPhone Application Development
Today I picked up a book called "Sams Teach Yourself iPhone Application Development in 24 Hours". Hopefully with this book I will make my own app to share with the world.
I've actually done a lot of reading about iOS development. There are some parts in this book that I read very quickly. I paid more attention to Hour 6 onwards. It discussed the Model View Controller Application Design topic which I still have a hard time understanding.
To make things harder, I am using Xcode 4.2 which is a different version than what the book is using, Xcode 4.0. So there are instructions which are done differently in the newer version. I had to look up online on how to implement the old instructions in the new environment.
So this is my understanding so far.
The chapter started off with the explanation of the Model View Controller (better known as MVC). This is the application design that was adopted by Apple to create application for iOS devices and the Macs. MVC is divided into 3 parts:
Model - this is the object that provides information to the rest of the application.
View - this is responsible for the user interface of the application.
Controller - the bridge that handles information and user action from the Model and View objects.
The application to create in this project is a Single View Application with 2 labels, 1 textfield and a button. One label is "Hello", and the other one is supposed to be what user inputted in the textfield after the button is pressed. All the labels, textfield and button are placed in a storyboard which altogether make up the View part of the application.
The Controller part is handled by the "File's Owner". But since this is a relatively simple example, the "File's Owner" seems to be half Controller half Model. So those are the things that make up the whole application.
So how do they interact with each other? There is something that is called Markers and they are IBAction and IBOutlet. IBAction is a set of methods that is triggered whenever user interacts with the interface, for example pressing a button. IBOutlet is a path that links code to View. It is used to read and write values. In this case, the IBOutlet is linked to the second label and the textfield while IBAction is linked to the button.
The other important part in this Hour is the @property and @synthesize directives. They allow objects to use the dot notation, for example object.text=object2.text.
Lastly, the garbage collection. Every objects that are created in iOS has to be released. This is done using the dealloc method. Release all the objects created and end with [super dealloc].
So far so good. I'm understanding the concept better after reading this chapter now.