How to Use Frameworks in Your iPad App - dummies

By Neal Goldstein, Tony Bove

A framework offers common code that provides generic functionality. The iPhone OS for the iPad provides a set of frameworks for incorporating technologies, services, and features into your apps. For example, the UIKit framework gives you event-handling support, drawing support, windows, views, and controls you can use in your app.

A framework is designed to easily integrate your code that runs your game or delivers the information that your user wants. Frameworks are similar to software libraries, but with an added twist: They also implement a program’s flow of control (unlike a software library whose components are arranged by the programmer into a flow of control). So, instead of the programmer deciding the order that things should happen — such as which messages are sent to which objects and in what order when an application launches, or when a user touches a button on the screen — the order is a part of the framework and doesn’t need to be specified by the programmer.

When you use a framework, you provide your app with a ready-made set of basic functions; you’ve told it, “Here’s how to act.” With the framework in place, all you need to do is add the specific functionality that you want in the app — the content, as well as the controls and views that enable the user to access and use that content — to the frameworks.

The frameworks and the iPhone OS for the iPad provide some pretty complex functionality, such as

  • Launching the app and displaying a view

  • Displaying controls and responding to a user action — such as tapping a toggle switch or flicking to scroll a list.

  • Accessing sites on the Internet — not just through a browser, but from within your own app

  • Managing user preferences

  • Playing sounds and movies

Some developers talk in terms of “using a framework” — but your app doesn’t use frameworks so much as the frameworks use your app. Your app provides the functions that the framework accesses; the framework needs your code in order to become an app that does something other than start up, display a blank view, and then end. This perspective makes figuring out how to work with a framework much easier. (For one thing, it lets the programmer know where he or she is essential.)