How to Use Frameworks to Develop an iOS App

By Jesse Feiler

A framework offers common code that provides generic functionality for your iOS app. The iOS SDK 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 that you can use in your app.

A framework is designed to easily integrate the code that runs, say, an app or game or that delivers the information your user wants. A framework is similar to a software library, but with an added twist: It can also implement a program’s flow of control (in contrast to a software library, whose components are arranged by the programmer into a flow of control).

So, when working within a framework, the programmer may not have to decide the order in which things should happen — such as which messages are sent to which objects and in what order when an app launches, or when a user touches a button on the screen. Instead, the order of those events, or flow of control, may be a part of the framework.

When you use a framework, it provides your app with a ready-made set of basic functions; essentially 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.

The frameworks and iOS provide pretty complex functionality, such as

  • Launching the app and displaying a window on the screen

  • Displaying controls on the screen and responding to a user action — changing a toggle switch, for example, or scrolling a view, such as the list of your contacts

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

  • Managing user preferences

  • Playing sounds and movies

Some developers talk in terms of “using a framework” — but in reality, your code doesn’t use the framework so much as the framework uses your code. Your code provides the functions that the framework accesses; the framework needs your code to become an app that does something other than start up, display a blank window, and end. This perspective makes figuring out how to work with a framework much easier.

If this seems too good to be true, well, okay, it is — all that complexity (and convenience) comes at a cost. It can be really difficult to get your head around the whole thing and know exactly where (and how) to add your app’s functionality to the functionality that the framework supplies.

That’s where design patterns come in. Understanding the design patterns behind the frameworks gives you a way of thinking about a framework — especially UIKit because it’s based on the MVC design pattern — that doesn’t make your head explode.