App Design Basics

If you are new to developing iOS apps, you might be wondering where the app development process starts. After devising your initial idea for an app, you need to turn that idea into an action plan for implementing your app. From a design perspective, you need to make some high-level decisions about the best course of action for implementing your ideas. You also need to set up your initial Xcode project in a way that makes it easy to proceed with development.

If you are new to developing iOS apps altogether, spend some time familiarizing yourself with the basic concepts. There are tutorials to help you jump right in if you want to start writing code, but iOS is a system built from basic design patterns. Taking a little bit of time to learn those patterns will help you tremendously later.

Doing Your Initial Design

There are many ways to design an app, and many of the best approaches do not involve writing any code. A great app starts with a great idea that you then expand into a more full-featured product description. Early in the design phase, it helps to understand just what you want your app to do. Write down the set of high-level features that would be required to implement your idea. Prioritize those features based on what you think your users will need. Do a little research into iOS itself so that you understand its capabilities and how you might be able to use them to achieve your goals. And sketch out some rough interface designs on paper to visualize how your app might look.

The goal of your initial design is to answer some very important questions about your app. The set of features and the rough design of your interface help you think about what will be required later when you start writing code. At some point, you need to translate the information displayed by your app into a set of data objects. Similarly, the look of your app has an overwhelming influence on the choices you must make when implementing your user interface code. Doing your initial design on paper (as opposed to on the computer) gives you the freedom to come up with answers that are not limited by what is easy to do.

Of course, the most important thing you can do before starting your initial design is read iOS Human Interface Guidelines. That book describes several strategies for doing your initial design. It also offers tips and guidance about how to create apps that work well in iOS. You might also read iOS Technology Overview to understand how you might use the capabilities of iOS to achieve your design goals.

Learning the Fundamental iOS Design Patterns and Techniques

No matter what type of app you are creating, there are a few fundamental design patterns and techniques that you must know before you start writing code. In iOS, the system frameworks provide critical infrastructure for your app and in most cases are the only way to access the underlying hardware. In turn, the frameworks use many specific design patterns and assume that you are familiar with them. Understanding these design patterns is therefore an important first step to understanding how the system can help you develop your app.

The most important design patterns you must know are:

Accurate and efficient memory management is important for iOS apps. Because iOS apps typically have less usable memory than a comparable desktop computer, apps need to be aggressive about deleting unneeded objects and be lazy about creating objects in the first place. Apps use the compiler’s Automatic Reference Counting (ARC) feature to manage memory efficiently. Although using ARC is not required, it is highly recommended. The alternative is to manage memory yourself by explicitly retaining and releasing objects.

There are other design patterns that you might see used occasionally or use yourself in your own code. For a complete overview of the design patterns and techniques you will use to create iOS apps, see Start Developing iOS Apps Today.

Translating Your Initial Design into an Action Plan

iOS assumes that all apps are built using the Model-View-Controller design pattern. Therefore, the first step you can take toward achieving this goal is to choose an approach for the data and view portions of your app.

Starting the App Creation Process

After you formulate your action plan, it is time to start coding. If you are new to writing iOS apps, it is good to take some time to explore the initial Xcode templates that are provided for development. These templates greatly simplify the work you have to do and make it possible to have an app up and running in minutes. These templates also allow you to customize your initial project to support your specific needs more precisely. To that end, when creating your Xcode project, you should already have answers to the following questions in mind:

From these questions, you can use Xcode to create your initial project files and start coding.

  1. If you have not yet installed Xcode, do so and configure your iOS development team. For detailed information about setting up your development team and preparing your Xcode environment, see App Distribution Guide.

  2. Create your initial Xcode project.

  3. Before writing any code, build and run your new Xcode project. Target your app for iOS Simulator so that you can see it run.

    Every new Xcode project starts you with a fully functional (albeit featureless) app. The app itself should run and display the default views found in the main storyboard or nib file, which are probably not very interesting. The reason that the app runs at all, though, is because of the infrastructure provided to you by UIKit. This infrastructure initializes the app, loads the initial interface file, and checks the app in with the system so that it can start handling events. For more information about this infrastructure and the capabilities it provides, see “The Core Objects of Your App” and “The App Launch Cycle.”

  4. Start writing your app’s primary code.

    For new apps, you probably want to start creating the classes associated with your app’s data model first. These classes usually have no dependencies on other parts of your app and should be something you can work on initially. For information about ways to build your data model, see “The Data Model.”

    You might also want to start playing around with designs for your user interface by adding views to your main storyboard or nib file. From these views, you can also start identifying the places in your code where you need to respond to interface-related changes. For an overview of user interfaces and where they fit into your app’s code, see “The User Interface.”

    If your app supports iCloud, you should incorporate support for iCloud into your classes at an early stage. For information about adding iCloud support to your app, see “Integrating iCloud Support Into Your App.”

  5. Add support for app state changes.

    In iOS, the state of an app determines what it is allowed to do and when. App states are managed by high-level objects in your app but can affect many other objects as well. Therefore, you need to consider how the current app state affects your data model and view code and update that code appropriately. For information about app states and how apps run in the foreground and background, see “App States and Multitasking”

  6. Create the resources needed to support your app.

    Apps submitted to the App Store are expected to have specific resources such as icons and launch images to make the overall user experience better. Well-factored apps also make heavy use of resource files to keep their code separate from the data that code manipulates. This factoring makes it much easier to localize your app, tweak its appearance, and perform other tasks without rewriting any code. For information about the types of resources found in a typical iOS app and how they are used, see “The App Bundle” and “App-Related Resources.”

  7. As needed, implement any app-specific behaviors that are relevant for your app.

    There are many ways to modify the way your app launches or interacts with the system. For information about the most common types of app customizations, see “Advanced App Tricks.”

  8. Add the advanced features that make your app unique.

    iOS includes many other frameworks for managing multimedia, advanced rendering, game content, maps, contacts, location tracking, and many other advanced features. For an overview of the frameworks and features you can incorporate into your apps, see iOS Technology Overview.

  9. Do some basic performance tuning for your app.

    All iOS apps should be tuned for the best possible performance. Tuned apps run faster but also use system resources, such as memory and battery life, more efficiently. For information about areas to focus on during the tuning process, see “Performance Tuning.”

  10. Iterate.

    App development is an iterative process. As you add new features, you might need to revisit some or all of the preceding steps to make adjustments to your existing code.

Best Practices for Maintaining User Privacy

Maintaining user privacy should be an important consideration when designing your app. Most iOS devices contain user and device data that users might not want to expose to apps or external entities. If your app uses user or device data in an unexpected way, the user might delete your app rather than trust it to use the data in an appropriate way.

You should access user or device data only with the user’s informed consent obtained in accordance with applicable law. In addition, you should take appropriate steps to protect user and device data and be transparent about how you use it. Here are some best practices that you can take:

Table 1-1 lists the types of data authorizations supported by iOS. Using the services listed in this table causes an alert to be displayed to the user requesting permission to do so. You can determine if the user authorized your app for a service using the API listed for each item. You should view this table as a starting point for your app’s own privacy behaviors and not as a finite checklist. The contents of this table may evolve over time.

Table 1-1  Data protected by system authorization settings

Data

System authorization support

Location

The authorization status for location data is available from the authorizationStatus class method of CLLocationManager. To inform the user about how you intend to use this information, include the NSLocationUsageDescription key in your Info.plist file.

Photos

The authorization status for photo data is available from the authorizationStatus method of ALAssetsLibrary. To inform the user about how you intend to use this information, include the NSPhotoLibraryUsageDescription key in your Info.plist file.

Music, video, and other media assets

The authorization status for media assets is available from the authorizationStatus method of ALAssetsLibrary.

Contacts

The authorization status for contact data is available from the ABAddressBookGetAuthorizationStatus function. To inform the user about how you intend to use this information, include the NSContactsUsageDescription key in your Info.plist file.

Calendar data

The authorization status for calendar data is available from the authorizationStatusForEntityType: method of EKEventStore. To inform the user about how you intend to use this information, include the NSCalendarsUsageDescription key in your Info.plist file.

Reminders

The authorization status for reminder data is available from the authorizationStatusForEntityType: method of EKEventStore. To inform the user about how you intend to use this information, include the NSRemindersUsageDescription key in your Info.plist file.

Bluetooth peripherals

The authorization status for Bluetooth peripherals is available from the state property of CBCentralManager. To inform the user about how you intend to use Bluetooth, include the NSBluetoothPeripheralUsageDescription key in your Info.plist file.

Microphone

In iOS 7 and later, the authorization status for the microphone is available from the requestRecordPermission: method of AVAudioSession. To inform the user about how you intend to use the microphone, include the NSMicrophoneUsageDescription key in your Info.plist file.

Camera

In iOS 7 and later, the authorization status for the camera is available in deviceInputWithDevice:error: method of AVCaptureDeviceInput. To inform the user about how you intend to use the camera, include the NSCameraUsageDescription key in your Info.plist file.