App Development Process
Although the task of developing an app may seem daunting, the process can be distilled into several digestible steps. The steps that follow will help you get started and guide you in the right direction as you develop your first app.
Defining the Concept
Every great app starts with a concept.
The best way to arrive at that concept is to consider the problem you want your app to solve. Great apps solve a single, well-defined problem. For example, the Settings app allows users to adjust all of the settings on their device. It provides a single interface for users to accomplish a related set of tasks.
Here are some key questions to consider when arriving at a concept:
Who is your audience? Your app content and experience will differ depending on whether you’re writing a children’s game, a to-do list app, or even a test app for your own learning.
What is the purpose of your app? It’s important for an app to have a clearly defined purpose. Part of defining the purpose is understanding what one thing will motivate users to use your app.
What problem is your app trying to solve? An app should solve a single problem well instead of trying to offer solutions to multiple distinct problems. If you find that your app is trying to solve unrelated problems, you might consider writing multiple apps.
What content will your app incorporate? Consider what type of content your app will present to users and how they’ll interact with it. Design the user interface to complement the type of content that’s presented in the app.
An app concept doesn’t have to be completely polished or finished when you start developing your app. Still, it helps to have an idea of where you’re going and what you need to do to get there.
Designing a User Interface
After you have a concept for your app, designing a good user interface is the next step to creating a successful app. A user needs to be able to interact with the app interface in the simplest way possible. Design the interface with the user in mind, and make it efficient, clear, and straightforward.
Perhaps the most challenging thing about building a user interface is translating your concept into a design and then implementing that design. To help simplify this process, use storyboards. Storyboards let you design and implement your interface in a single step using a graphical environment. You can see exactly what you’re building while you’re building it, get immediate feedback about what’s working and what’s not, and make instantly visible changes to your interface.
When you build an interface in a storyboard, you’re working with views. Views display content to the user. In Tutorial: Basics, you began to define a user interface for the ToDoList app using a single view in a storyboard scene. As you develop more complex apps, you’ll create interfaces with more scenes and more views.
In Tutorial: Storyboards, you’ll finish building the user interface for your ToDoList app using several different views to display different types of content. You’ll learn more about working with views and storyboards to design and create a user interface in Designing a User Interface.
Defining the Interaction
A user interface doesn’t do much without any logic backing it. After you’ve created an interface, you define how users can interact with what they see by writing code to respond to user actions in your interface.
Before you start thinking about adding the behaviors for your interface, it’s important to understand that iOS apps are based on event-driven programming. In event-driven programming, the flow of the app is determined by events: system events or user actions. The user performs actions on the interface, which trigger events in the app. These events result in the execution of the app’s logic and manipulation of its data. The app’s response to user action is then reflected back in the interface.
As you define how a user can interact with your interface, keep event-driven programming in mind. Because the user, rather than the developer, is in control of when certain pieces of the app code get executed, you want to identify exactly which actions a user can perform and what happens in response to those actions.
You define much of your event-handling logic in view controllers. You’ll learn more about working with view controllers in Defining the Interaction. Afterward, you’ll apply these concepts to add functionality and interactivity to your ToDoList app in Tutorial: Storyboards.
Implementing the Behavior
After you’ve defined the actions a user can perform in your app, you implement the behavior by writing code.
When you write code for iOS apps, most of your time is spent working with the Objective-C programming language. You’ll learn more about Objective-C in the third module, but for now, it helps to have some basic familiarity with the vocabulary of the language.
Objective-C is built on top of the C programming language and provides object-oriented capabilities and a dynamic runtime. You get all of the familiar elements, such as primitive types (
float, and so on), structures, functions, pointers, and control flow constructs (
for statements). You also have access to the standard C library routines, such as those declared in
Objects Are Building Blocks for Apps
When you build an iOS app, most of your time is spent working with objects.
Objects package data with related behavior. You can think of an app as a large ecosystem of interconnected objects that communicate with each other to solve specific problems, such as displaying a visual interface, responding to user input, or storing information. You use many different types of objects to build your app, ranging from interface elements, such as buttons and labels, to data objects, such as strings and arrays.
Classes Are Blueprints for Objects
A class describes the behavior and properties common to any particular type of object.
In the same way that multiple buildings constructed from the same blueprint are identical in structure, every instance of a class shares the same properties and behavior as all other instances of that class. You can write your own classes or use framework classes that have been defined for you.
You make an object by creating an instance of a particular class. You do this by allocating it and initializing it with acceptable default values. When you allocate an object, you set aside enough memory for the object and set all instance variables to zero. Initialization sets an object’s initial state—that is, its instance variables and properties—to reasonable values and then returns the object. The purpose of initialization is to return a usable object. You need to both allocate and initialize an object to be able to use it.
One of the fundamental concepts in Objective-C programming is class inheritance, the idea that a class inherits behaviors from a parent class. When one class inherits from another, the child—or subclass—inherits all the behavior and properties defined by the parent. The subclass can define its own additional behavior and properties or override the behavior of the parent. This gives you the ability to extend the behaviors of a class without duplicating its existing behavior.
Objects Communicate Through Messages
Objects interact by sending each other messages at runtime. In Objective-C terms, one object sends a message to another object by calling a method on that object.
Although there are several ways to send messages between objects in Objective-C, by far the most common is the basic syntax that uses square brackets. If you have an object
somePerson of class
Person, you can send it the
sayHello message like this:
The reference on the left,
somePerson, is the receiver of the message. The message on the right,
sayHello, is the name of the method to call on that receiver. In other words, when the above line of code is executed,
somePerson will be sent the
Protocols Define Messaging Contracts
A protocol defines a set of behavior that’s expected of an object in a given situation. A protocol comes in the form of a programmatic interface, one that any class may choose to implement. Using protocols, two classes distantly related by inheritance can communicate with each other to accomplish a certain goal, such as parsing XML code or copying an object.
Any class that can provide behavior that’s useful to other classes can declare a programmatic interface for vending that behavior anonymously. Any other class can choose to adopt the protocol and implement one or more of its methods, making use of the behavior.
Incorporating the Data
After you implement your app’s behavior, you create a data model to support your app’s interface. An app’s data model defines the way you maintain data in your app. Data models can range from a basic dictionary of objects to complex databases.
Your app’s data model should reflect the app’s content and purpose. There should be a clear correlation between the interface and the data, even though the user doesn’t interact with the data directly.
A good data model is essential to creating a solid foundation for your app. It makes it easier to build a scalable app, improve functionality, and make changes to your features. You’ll learn more about defining your own data model in Incorporating the Data.
Use the Right Resources
Design patterns are best practices for solving common problems in apps. Use design patterns to help you define the structure of your data model and its interaction with the rest of your app. When you understand and use the right design patterns, you can more easily create an app that’s simple and efficient. You’ll learn more about design patterns in Using Design Patterns.
As you start implementing your model, remember that you don’t have to implement everything from scratch. There are a number of frameworks that provide existing functionality for you to build upon. For instance, the Foundation framework includes classes representing basic data types—such as strings and numbers—as well as collection classes for storing other objects. It’s recommended that, where possible, you use existing framework classes—or subclass them to add your own app’s features—instead of trying to reimplement their functionality. In this way, you can create an efficient, functional, sophisticated app. You’ll learn more about the capabilities of the Foundation framework in Working with Foundation.
Often, you’ll write your own custom classes as part of your data model. Writing a custom class gives you control over how you organize the internal structure of your app. You’ll learn about creating custom classes in Writing a Custom Class.
Incorporate Real Data
When you first test your data model, you may want to use static or fake data. This way, you don’t have to worry about supplying real data until you know the model is assembled and connected properly. After you’ve defined a data model that’s working properly, you can pull real data into your app.
The remainder of this guide takes you through these steps in more detail. As you make your way through the app development process, you’ll learn the necessary conceptual material and then put it to use in the tutorials.