Overview of iPhone application development
Developing software on the IPhone has become a very attractive platform for developers. The reason is not only because nearly everyone owns an IPhone, it is because there is a rich and comprehensive, yet easy to use development kit for the iPhone. The framework for the iphone is provided by apple, and is called the Iphone software development kit, or SDK for short. These frame works contain all the code that your iphone needs to perform any functions or process.
The iphone SDK framework has been designed to easily allows you to intergrate any code for your specific functions for your application. A framework is basically a library of all the data functionality that your iphone can handle, include in the software and the hardware of the iphone.
The iphone framework is also excellent at controlling the flow of control and execution of your program. This means that you won't have to program the order that your functions should happen, this is taken care of by the SDK. You also as an iphone programmer, are able to just skip programming parts such as what data is sent where, and how to react to someone touching the button. All of this fucntionality is easily taken care of again with the SDK framework of the Iphone.
Its this reason that we are always hearing about apple games and programs being developed ina matter of a couple of weeks. Programming the iphone has been made as easy as posiible so you get to concentrate on eactly what your content application is.
The framework of the Iphone helps comelete large amounts of functionality including starting your application, and displaying it correctly on the screen. The SDK also takes care of the interface functionality, such as menu scrolling, when you touch the screen. Loading up to external internet sites and displaying data through your application is also taken care of, this is great when you are developing a high score table for a game. This data can easily be loaded up from your website.
Media handling is also taken care of, so as long as you supply the video and the audio that your application uses, then the iphone will handle how it is displayed on the screen, and also how the audio is played.
Using Design Patterns
The way that the iphone sdk framework is presented is through a concept called design patterns. Design patterns help you understand how to actually read the framework better, and learn how it is structured. They also indicate how your own application code should be written.
With iphone designs patterns you can think of them like the roadmap between all the individual functionality and objects of the frame work. The design patterns describe the relationships between the classes and the objects that you will be working with.
Design patterns come in 3 different varieties, and they include the MVC (Model view controller, delegation, and the target action.
The Model-View-Controller (MVC) pattern
The framework for the Iphone is what is known as object orientated. This is a type of programming style which basically breaks all your data, and process down to objects. These objects can then be controlled, via a relationship model, to indicate how they should react together. This might seem like the obvious way to program, but programming like this is relativly recent, compared to the very first programming languages that didn't require this degree of complexity. In saying that, using OOP is a far better way, and helps you understand your application writing much easier. Its also great for trouble shooting too, as problems can be tied to speciif areas, and functions.
Another great conecpt of OOP is that the code that you use is easily re-usable, and can be deployed elsewhere, and even easily extended. The best way to help you develop your mind to get used to this method of programming is just to consider the real world. Take an animal for instance. A cow is an object. It has a number of functions including eating grass. This function of eating grass would then start a relationship function with the ground. The ground would be an object itself. Different functions would take place with the ground, when the cow either eats it, or stands on it.
Something that also helps me when programming is think of what what is required if you lift the cow up into the air. The space between the ground and the cow is now up to you to decide what will happen. You could have the cow turning pink, if it touches the ground, or exploding if it eats the grass. This is an example of changing the functionality of the objects. Yet in both the examples the two objects, the cow and the ground, remained the same. The only change was the functions that held those relationships together.
The MVC of the Iphone SDK is a method to group your application functions into objects. This would mean in our example that we could group the first functions into a group called normal, and then the funny actions into a group called funny. They are then now objects, and could be applied to other objects. If you add a cat, you can now have the cat, being affected by both of these function objects, and you won't have to write any new code for the cat. Well, you might have to write a little function that the cat is sick when it eats the grass, that's what my cat always done!
The MVC pattern helps create an application that has three parts to it, as well as the responsibility of these three parts, and how they interact.
Model objects, and these are made up of the logic and data that your application is dealing with. This would include the color of the grass, the size of the cow, and how to know that the cow has begun eating the grass.
The model objects will have no objection to what you do with it, and will only supply the data that you ask for. It won't make decisions about what you are doing with that data.
There are also:
View objects, which are used to display what you want on the iphone screen, and how your application will respond to these actions. Anything that can be touched on the iphone will have an equivalent view object. The view object will collect any required data from the model objects, such as the color to display the cow in the funny example. The model will tell it pink, and the view object will then take care of changing the cow to a pink cow.
Now the final object is:
Controller object, which is the easiest object type to understand. The controller object is like the office temp, it does all your running around for you. Since the model objects and the view objects need to communicate information the controller will go between them and pass the data. How does the iPhone know what the color pink actually is, and where to paint it? well the controller object will retrieve this information from the Model objects, and pass it to the display, and everyone is happy.