Home > Articles > Mobile Application Development & Programming

Know Your Tools to Build Better iOS Apps

iOS engineering manager Joe Keeley, author of Mastering iOS Frameworks: Beyond the Basics, 2nd Edition, takes a brief look at some of the most commonly used tools in iOS development, and introduces some specific things that a new developer can learn to get a lot of leverage and improve their development skills.
Like this article? We recommend

One technique for new iOS developers who want to up their game is just to get more familiar with the tools of the trade. By understanding what tools are available and how to use those tools, developers can write code that is shorter, simpler, faster, and easier to maintain.

In this article, we’ll take a brief look at some of the most commonly used tools in iOS development, and some specific things that a new developer can learn to get a lot of leverage.

Xcode

Xcode is the integrated development environment that Apple provides for iOS development. A developer will use Xcode to set up a new project, build out a user interface in Storyboard, build and edit class files, run and debug a project, resolve performance issues with Instruments, and package and submit apps to the App Store.

  • Storyboards: There are two critical techniques to know about storyboards. First is the ability to quickly build out a user interface. With a storyboard, a skilled developer can build out the user interface for an app quickly, including navigation and basic interactions with no code. Second are Size Classes and Auto Layout. With effective use of these, a skilled developer can handle different device sizes and orientations all in the Storyboard, again with little to no code. Size Classes can even support completely different layouts on different devices. Reducing the amount of code in the project reduces the potential for bugs and long-term technical debt. More details about Auto Layout and Size Classes are available at the Apple Developer website, and in WWDC videos 2014: Session 216, “Building Adaptive Apps with UIKit“ and Session 411, “What’s New in Interface Builder.”
  • Debugging and Basic Profiling: All code has bugs, and some bugs are more difficult to diagnose and resolve than others. Xcode has a powerful debugger (lldb) built in that can be a great aid in diagnosing and resolving bugs. The debugger can display previews of objects in code, including images (hint: implement the description method in your objects to display extra detail). It can set breakpoints with many different and useful variations: logging breakpoints to print information to the console without adding log statements to your code; conditional breakpoints to stop only when specified criteria are met; action breakpoints can run a script or play a sound when a breakpoint is hit; exception breakpoints stop when Objective-C exceptions are thrown, making it easier to trace crashes when they happen; and symbolic breakpoints to stop action when a method name is called, even if the source for that method is not available. In addition to the debugger, Xcode provides a basic profiler in the debugging view to show memory and CPU utilization while debugging an app. This view can help a developer identify performance problems in the app, which can then be investigated in detail using Instruments. Chapter 26, “Debugging and Instruments” in Mastering iOS Frameworks provides an introduction to all these topics.

iOS SDK

Apple has many years of investment in the iOS (Cocoa Touch) SDK. iOS has its roots in OS X, the Macintosh operating system, and even shares some code with it in the Foundation classes. From basic technologies like buttons and labels to show on a view, to more advanced technologies like collection views, to relatively obscure technologies like Core Image or Handoff, the SDK contains a wealth of functionality and power available for the developer to discover and leverage.

  • Getting off the main queue: One of the biggest leaps a developer can make is being able to use background queues effectively to reduce the amount of load on the main queue. This requires understanding the techniques available to execute code off the main queue, knowing how to coordinate any background activity with updating the user interface, and preventing some of the pitfalls of working in background queues like deadlocks, race conditions, or inconsistent user interface updates. Working off the main queue requires knowledge of NSObject methods, NSOperations and NSOperationQueues, and Grand Central Dispatch techniques. These techniques are described in detail in Chapter 18, “Grand Central Dispatch for Performance” in Mastering iOS Frameworks.
  • Networking: Many apps need to use networking to communicate with the outside world. Apple has updated the internal networking stack as of iOS 7 (NSURLSession and NSURLSessionTask). With the new tools, Apple provides lots of powerful networking capabilities. When combined with NSJSONSerialization for JSON parsing and NSURLCache for request and image caching, a developer can do everything that popular third-party libraries do and still know what is going on under the hood. Some of these techniques are used in the sample apps used throughout Mastering iOS Frameworks, and Chapter 9, “Working with and Parsing JSON” describes how to deal with JSON specifically.
  • Frameworks for specific purposes: Apple has a number of frameworks developed to support specific purposes, like using music libraries, interacting with the address book, storing and interacting with data using Core Data, using HomeKit or HealthKit, or adding Game Center to an app. Each of these frameworks requires specific knowledge to apply effectively in an app. Mastering iOS Frameworks provides many chapters that describe how to get up to speed on specific frameworks, with sample apps that illustrate the concepts and how to implement them.

Languages (Objective-C and Swift)

iOS apps can be built using Objective-C, Swift, or a combination of the two. Knowledge of Objective-C is still important, because the vast majority of the iOS SDK is written in Objective-C. Swift provides excellent interoperability with Objective-C code, and has a number of developer-friendly features like Playgrounds that make it a great option for developing faster and better.

  • Objective-C: With the dynamic nature of Objective-C, there are a number of techniques that are obscure but can be very valuable. For example, an Objective-C category allows a developer to add a method to an existing class, without having the source code for the original class. This can be very useful for adding utility methods to standard classes like NSString or UIImage. Using Key-Value concepts can be very powerful, both for observing and responding to changes in objects, and for performing bulk operations. Let’s say I have an array of people, and I need a list of names to show in a picker. Instead of iterating over the array, getting the name for each instance, and adding to another array, simply performing [myArrayOfPeople valueForKey:@“name”] will provide the list of names in one call. Finally, using blocks can be a very powerful technique in many use cases. Blocks are used extensively in the iOS SDK for things like completion handlers and enumeration handlers. Because blocks can contain both code and data, and are objects that can be stored in arrays or passed as method parameters, they provide a great deal of power and versatility.
  • Swift: Xcode includes a tool for learning, practicing, and developing Swift in an interactive way called a Playground. A Swift Playground is an abbreviated project with special settings to allow the compiler to evaluate and execute Swift code as you type, with a window to show results in real time. This lets the developer experiment and learn quickly because feedback is immediate. Swift is a strongly typed language that offers modern syntax and features. It supports pass by value structs and pass by reference classes, functions as types that can be passed around like objects, and optionals that explicitly handle cases where nil values can occur. All these features can be applied to write clean, tight, and comprehensible code. Swift was developed with specific support for interoperating with Objective-C. Many Objective-C classes are automatically converted to the equivalent Swift type, and some Swift types can be converted to Objective-C. Because the great majority of the iOS SDK is still in Objective-C, it is important to know how to interact with the Objective-C SDK from Swift. For a good introduction to Swift, check out Swift for the Really Impatient by Matt Henderson and Dave Wood.

Git (Version Control)

Git is a distributed version control system, originally written by Linus Torvalds. It is natively supported by Xcode, and is the default version control system for new projects created in Xcode. Using version control is absolutely required in a team project. For an indie developer, following the discipline of version control can avoid a lot of common problems, and make life easier when creating new versions and dot fixes, and integrating new features. Using remote repositories provides a great way to keep a backup of a project in addition to syncing changes between people or machines.

  • Branches: Using a branch is a good technique for adding a feature or working on a fix. A branch can be created from the current working directory, allowing any work to be isolated in one place. When work is complete, it can be discarded with no effect on the original code, or can be merged into the original code. Branches can be compared visually to see what differences there are between them.
  • Viewing history: When a feature unexpectedly breaks, looking at commit history in git can help a developer figure out what went wrong. History can be viewed by file across commits, and by commit across files. Git can also show who made changes in a source file (called blame) by line, making it easy to figure out who to ask if a line looks incorrect or does not make sense.
  • Remote repositories: A remote repository can be used both as a backup for a project’s source code and as a way to integrate changes from multiple developers. Services like GitHub and Bitbucket provide a quick and easy way to set up a remote repository for a project. Once the remote repository has been set up, local changes can be pushed to it, and remote changes can be pulled from it. Branches can be pushed and pulled from the remote repository independently. In GitHub, for example, a developer can create a pull request from one branch into another branch, and then request another developer to review it. This is a good technique to get extra eyes on code, discuss any potential problems, and ensure consistency in how problems are approached in a project. Once any potential changes have been addressed in the branch locally and pushed to the remote repository, they can then be merged on the remote repository directly.

More information about Git is available at http://git-scm.com, and information about using Git in Xcode is available at http://www.cimgf.com/2013/12/10/using-git-in-xcode.

Enjoy Learning

There are lots of opportunities for a new iOS developer to improve their skills, especially by getting more familiar with the tools commonly used for iOS development. From writing user interfaces that support multiple device sizes and orientations with no code in Xcode Storyboards, to adding utility methods to existing classes using Objective-C categories, to specific frameworks in the iOS SDK, to elegant and efficient code management using Git, a developer can find many techniques to reduce the amount of code written, improve the quality of that code, and make building apps more fun and rewarding. Enjoy exploring and learning!

InformIT Promotional Mailings & Special Offers

I would like to receive exclusive offers and hear about products from InformIT and its family of brands. I can unsubscribe at any time.

Overview


Pearson Education, Inc., 221 River Street, Hoboken, New Jersey 07030, (Pearson) presents this site to provide information about products and services that can be purchased through this site.

This privacy notice provides an overview of our commitment to privacy and describes how we collect, protect, use and share personal information collected through this site. Please note that other Pearson websites and online products and services have their own separate privacy policies.

Collection and Use of Information


To conduct business and deliver products and services, Pearson collects and uses personal information in several ways in connection with this site, including:

Questions and Inquiries

For inquiries and questions, we collect the inquiry or question, together with name, contact details (email address, phone number and mailing address) and any other additional information voluntarily submitted to us through a Contact Us form or an email. We use this information to address the inquiry and respond to the question.

Online Store

For orders and purchases placed through our online store on this site, we collect order details, name, institution name and address (if applicable), email address, phone number, shipping and billing addresses, credit/debit card information, shipping options and any instructions. We use this information to complete transactions, fulfill orders, communicate with individuals placing orders or visiting the online store, and for related purposes.

Surveys

Pearson may offer opportunities to provide feedback or participate in surveys, including surveys evaluating Pearson products, services or sites. Participation is voluntary. Pearson collects information requested in the survey questions and uses the information to evaluate, support, maintain and improve products, services or sites, develop new products and services, conduct educational research and for other purposes specified in the survey.

Contests and Drawings

Occasionally, we may sponsor a contest or drawing. Participation is optional. Pearson collects name, contact information and other information specified on the entry form for the contest or drawing to conduct the contest or drawing. Pearson may collect additional personal information from the winners of a contest or drawing in order to award the prize and for tax reporting purposes, as required by law.

Newsletters

If you have elected to receive email newsletters or promotional mailings and special offers but want to unsubscribe, simply email information@informit.com.

Service Announcements

On rare occasions it is necessary to send out a strictly service related announcement. For instance, if our service is temporarily suspended for maintenance we might send users an email. Generally, users may not opt-out of these communications, though they can deactivate their account information. However, these communications are not promotional in nature.

Customer Service

We communicate with users on a regular basis to provide requested services and in regard to issues relating to their account we reply via email or phone in accordance with the users' wishes when a user submits their information through our Contact Us form.

Other Collection and Use of Information


Application and System Logs

Pearson automatically collects log data to help ensure the delivery, availability and security of this site. Log data may include technical information about how a user or visitor connected to this site, such as browser type, type of computer/device, operating system, internet service provider and IP address. We use this information for support purposes and to monitor the health of the site, identify problems, improve service, detect unauthorized access and fraudulent activity, prevent and respond to security incidents and appropriately scale computing resources.

Web Analytics

Pearson may use third party web trend analytical services, including Google Analytics, to collect visitor information, such as IP addresses, browser types, referring pages, pages visited and time spent on a particular site. While these analytical services collect and report information on an anonymous basis, they may use cookies to gather web trend information. The information gathered may enable Pearson (but not the third party web trend services) to link information with application and system log data. Pearson uses this information for system administration and to identify problems, improve service, detect unauthorized access and fraudulent activity, prevent and respond to security incidents, appropriately scale computing resources and otherwise support and deliver this site and its services.

Cookies and Related Technologies

This site uses cookies and similar technologies to personalize content, measure traffic patterns, control security, track use and access of information on this site, and provide interest-based messages and advertising. Users can manage and block the use of cookies through their browser. Disabling or blocking certain cookies may limit the functionality of this site.

Do Not Track

This site currently does not respond to Do Not Track signals.

Security


Pearson uses appropriate physical, administrative and technical security measures to protect personal information from unauthorized access, use and disclosure.

Children


This site is not directed to children under the age of 13.

Marketing


Pearson may send or direct marketing communications to users, provided that

  • Pearson will not use personal information collected or processed as a K-12 school service provider for the purpose of directed or targeted advertising.
  • Such marketing is consistent with applicable law and Pearson's legal obligations.
  • Pearson will not knowingly direct or send marketing communications to an individual who has expressed a preference not to receive marketing.
  • Where required by applicable law, express or implied consent to marketing exists and has not been withdrawn.

Pearson may provide personal information to a third party service provider on a restricted basis to provide marketing solely on behalf of Pearson or an affiliate or customer for whom Pearson is a service provider. Marketing preferences may be changed at any time.

Correcting/Updating Personal Information


If a user's personally identifiable information changes (such as your postal address or email address), we provide a way to correct or update that user's personal data provided to us. This can be done on the Account page. If a user no longer desires our service and desires to delete his or her account, please contact us at customer-service@informit.com and we will process the deletion of a user's account.

Choice/Opt-out


Users can always make an informed choice as to whether they should proceed with certain services offered by InformIT. If you choose to remove yourself from our mailing list(s) simply visit the following page and uncheck any communication you no longer want to receive: www.informit.com/u.aspx.

Sale of Personal Information


Pearson does not rent or sell personal information in exchange for any payment of money.

While Pearson does not sell personal information, as defined in Nevada law, Nevada residents may email a request for no sale of their personal information to NevadaDesignatedRequest@pearson.com.

Supplemental Privacy Statement for California Residents


California residents should read our Supplemental privacy statement for California residents in conjunction with this Privacy Notice. The Supplemental privacy statement for California residents explains Pearson's commitment to comply with California law and applies to personal information of California residents collected in connection with this site and the Services.

Sharing and Disclosure


Pearson may disclose personal information, as follows:

  • As required by law.
  • With the consent of the individual (or their parent, if the individual is a minor)
  • In response to a subpoena, court order or legal process, to the extent permitted or required by law
  • To protect the security and safety of individuals, data, assets and systems, consistent with applicable law
  • In connection the sale, joint venture or other transfer of some or all of its company or assets, subject to the provisions of this Privacy Notice
  • To investigate or address actual or suspected fraud or other illegal activities
  • To exercise its legal rights, including enforcement of the Terms of Use for this site or another contract
  • To affiliated Pearson companies and other companies and organizations who perform work for Pearson and are obligated to protect the privacy of personal information consistent with this Privacy Notice
  • To a school, organization, company or government agency, where Pearson collects or processes the personal information in a school setting or on behalf of such organization, company or government agency.

Links


This web site contains links to other sites. Please be aware that we are not responsible for the privacy practices of such other sites. We encourage our users to be aware when they leave our site and to read the privacy statements of each and every web site that collects Personal Information. This privacy statement applies solely to information collected by this web site.

Requests and Contact


Please contact us about this Privacy Notice or if you have any requests or questions relating to the privacy of your personal information.

Changes to this Privacy Notice


We may revise this Privacy Notice through an updated posting. We will identify the effective date of the revision in the posting. Often, updates are made to provide greater clarity or to comply with changes in regulatory requirements. If the updates involve material changes to the collection, protection, use or disclosure of Personal Information, Pearson will provide notice of the change through a conspicuous notice on this site or other appropriate way. Continued use of the site after the effective date of a posted revision evidences acceptance. Please contact us if you have questions or concerns about the Privacy Notice or any objection to any revisions.

Last Update: November 17, 2020