iOS Development Basics with sample code

Introduction

Reading Apples reference guide for iOS developers can be a daunting task. It reads a bit like an encyclopedia, and IMHO its samples of code are overdone for the beginning developer. Apps are written in Objective-C, an object-oriented programming language.

If you are familiar with any other object-oriented programming language it shouldn’t be too difficult other than learning the syntax, but the structure of Objective-C should be familiar to you. With Xcodes phenomenal interface, you will be writing apps in no time.

If you have never done any programming before, you will find it very hard to follow along.

Screen Shot

The Code Structure

There are three parts to an iOS app (generally speaking). The h file, the m file, and the xib file (or as iOS programmers call it the NIB file).

In Xcode (depending on your layout) these files can be accessed from the left side of your screen. The last couple of years Apple has changed the interface of Xcode to make it easier to use for developers. By using the document tree a developer can easily go back and forth between coding and the interface as well as debug. It takes a little getting used to but once you have practiced using it, development moves along very efficiently.

The h file
The h file or header file is generally where you will create objects to be used throughout the iOS app like: buttons, windows etc.

The m file
The m file or implementation file is generally where you will define functions , methods and objects you have created. This file is where most of the action will take place to make your app work.

The xib file
The xib file or NIB file is the interface file. This file is where you will make changes to the interface like: background images, object placement, etc. Inside of the NIB, Xcode provides several pre-constructed portions that you can drag and drop onto the interface to expedite app development. To connect interface elements with code files there is also drag and drop functionality inside of Xcode.

Inside Xcode

You will notice inside the code files that most of the code functions start with NS, example: NSMutableArray. This comes from a library of early Objective-C code called NeXTstep that was used for interfacing and app development. The AppKit and FoundationKit libraries used to develop app classes all derived from NeXTstep software.

The Type of App

Depending on which type of application you will build, when you open Xcode you will have several different options that give you basic structures to use as the foundation of your app including: header files, implementation files and NIB files . You also have the option to choose whether you want your app to be specific for iPhone, iPad, or a universal app for both the iPad and iPhone.

Resources

A few recommended resources to get started in iOS App development:

Conclusion

Learning any new programming language can be a difficult task but anything worth doing is always difficult. You will find that with practice, using Apples Xcode and developing apps in iOS is rewarding. If it were easy, everyone would be doing it. If it were so easy everyone could do it, we would be out of jobs! Good luck as you begin your journey developing apps in iOS.