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.
If we talk about the project, then this is how your project looks like as of now.
We will now discuss the red marking in the above image for your First iPhone Application.
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.
If you open and see AppDelegate.swift you will see lot of functions like this
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.
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.
- applicationWillResignActive, as written this method can be used for pausing current tasks as the application is about to enter an inactive state.
- applicationDidEnterBackground, if our application supports background modes then this method is called as soon as the application enters in the background.
- applicationWillEnterForeground, when the application is transitioned from background state to active state, this method is called.
- 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.
- 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.
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.