Understanding First iPhone Application: Part-1

iOS Tutorials: Understanding First iPhone Application

If you want to see how we can create an iPhone Application, please visit this article.

Now let’s understand Our very first created iPhone App.

Understanding First iPhone Application

We will now try to understand the need for all the files which are created in the application and what are the key files and what is the importance of these files.

As of now, this is how your first iPhone Application Looks like.

 

iOS Tutorials: Hello World.
iOS Tutorials: Hello World.

If we talk about the project, then this is how your project looks like as of now.

iOS Tutorials: Understanding First iPhone Application
Understanding First iPhone Application

We will now discuss the red marking in the above image for your First iPhone Application.

Navigation Panel

In this area you can see all the files which are used in the project, whenever we create a simple “Single View Application“, these are the default files gets created. We will be discussing them in detail now.

AppDelegate.swift

If you open and see AppDelegate.swift you will see lot of functions like this

iOS Tutorials: Understanding AppDelegate
Understanding AppDelegate.swift

 

AppDelegate:

AppDelegate is one of the most important files in our project. This provides some basic functionality for running and managing an application. It is from the Cocoa Touch Library. AppDelegate is derived from NSObject class. NSObject class is the Parent of all classes. Once the application has launched then the first thing which is going to be executed is the AppDelegate. Now let’s understand their method and its usages.

App Flow:

 

iS Tutorials: iPhone Application App Flow
iPhone Application App Flow

Functions in AppDelegate:

  • didFinishLaunchingWithOptions method is the first method which is called when the application is ready to perform and go ahead.
    • We can perform here tasks like setting custom root controller, custom navigation bar, register for push notifications etc.

 

iOS Tutorials: Understanding AppDelegate
Understanding AppDelegate
  • applicationWillResignActive, as written this method can be used for pausing current tasks as the application is about to enter an inactive state.

 

iOS Tutorials: Understanding applicationWillResignActive method.
Understanding applicationWillResignActive method.
  • applicationDidEnterBackground, if our application supports background modes then this method is called as soon as the application enters in the background.

 

iOS Tutorials: Understanding applicationDidEnterBackground.
Understanding applicationDidEnterBackground
  • applicationWillEnterForeground, when the application is transitioned from background state to active state, this method is called.

 

iOS Tutorials: Understanding willEnterForeground method .
Understanding willEnterForeground method.
  • applicationDidBecomeActive, this method tells us that the application has entered the active state and from here onwards we can perform the resumed tasks when were paused a while ago.

 

iOS Tutorials: Understanding didBecomeActive method.
Understanding didBecomeActive method.
  • applicationWillTerminate, when the application is about to be terminated (may be due to longtime in-activity in the background). OS terminates the application; at times user terminates the application by manually removing it from the background.

 

iOS Tutorials: Understanding applicationWillTerminate method.
Understanding applicationWillTerminate method.

Note: Please refer our next article for more details on the other files, please view the article from the link here.

If we want to play with different states of the application and make sure that transition of the application from background to foreground is smooth and not having any glitch, then all the operations need to be taken care of should be handled here in these methods

We hope you are done with creating your first iPhone Application, you can download the project from the link here.

Author: Chandra.rao

iOS Developer. #Life of an developer.... Learn New technology, Code, Learn New Technology, Code, Death.