Learn How to Make Apps for iOS Devices

how to make apps for iosEver wonder how the world of smartphones has changed our lives? It’s difficult to remember the last time you sent an SMS to a person and not used a smartphone app. Using applications on your phone is second nature nowadays. But, it all started with one revolutionary product, the iPhone, powered by iOS. With the ever increasing repository of apps in the iStore, as a developer, you should look to tap this market.

iOS is a mobile operating system developed by Apple Inc. and is exclusively available on Apple hardware. The interface provided by iOS is very intuitive and user-friendly. It was only after the iPhone entered the phone market that other competing OSes were developed. Why would you select iOS application development? Developing apps in iOS is all about user interface.  Security is one of the biggest reason people prefer the iOS-based iPhones. Since Apple reviews all the apps that make it to the store and verification of an app publisher is mandatory, malware attacks are less prominent.

New to iOS programming? Take a course at Udemy.com.

Before you begin

In order for you to start creating applications for iOS devices, take a look at the pre requisites:

  • Xcode IDE – If you want to get started with developing apps for iOS, you need to work with the Xcode Integrated Development Environment. Though the highlight of this tool is that it is a code editor, just like Eclipse, it comes with certain additional features and tools. Some of the examples are auto-complete support, static code analysis to find bugs in the code before compilation, and various debugging and performance tools. Xcode can also be used to compile your code through command line. If you are comfortable with other tools for command line compilation, you can use those too.
  • Interface Builder – When creating apps for iOS, do not underestimate the importance of visual and intuitive interface. Interface Builder provides in built buttons, tab bars, sliders, and labels that you can drag on your app interface, and then modify using palettes. You can also use it to manipulate binders and object bindings. This means you can define how the app should respond when a particular button or element is touched by the user.
  • Frameworks – With Apple providing a variety of frameworks, you can create user interfaces, networking code, encryption of information, draw graphics, play visual aids, save passwords, and much in a jiffy. The variety of frameworks offered are tremendous and can be found under the /Developer directory.
  • Programming basics – Objective C is most commonly used language by iOS programmers to create native apps. You also need to have knowledge of JavaScript to go ahead with creating applications.

Take a course at Udemy.com to master the art of iOS programming.

Creating a Hello World application

Let’s understand how to actually create an application after ensuring that all the pre-requisites are met. We will create a simple application that displays “Hello World” after you tap the “OK” icon on the screen. We will be using Xcode version 5 and Interface builder to create this app. Since we are creating an iOS app, you would need a Mac machine to complete this exercise.

  1. Launch the Xcode application and create a new Xcode project. Select the “create an empty application” option. Provide the name of the app and the device for which you are creating the app. Provide the location to store the app and click ok. The Hello World project is automatically created for you.
  2. Right-click the Hello World folder in the project navigator and click “New File”. Select the “Objective-C class” template under the “Cocoa Touch” category. Provide a name to the new class, let’s say we name it “HelloWorldtoUdemy.class”. Select the subclass as “UIViewController”, and ensure you select the “With XIB for user interface” checkbox.
  3. After you click “Create”, Xcode generates three files, namely “HelloWorldtoUdemy.h”, “HelloWorldtoUdemy.m”, and “HelloWorldtoUdemy.xib”. Open the “HelloWorldtoUdemy.xib” file to view a display box similar to the iPhone screen. Let us edit this view to add the “Hello World button” to it.
  4. From the “Object” library, under the “Utilities” area, drag a button to the view. Rename the button to Hello World. Now, if you run your project, you will not be able to see the button. This is because we need to tell the app to load a new view. To do this, open the “AppDelegate.m” file, and add the following line to the beginning of the code:
#import “HelloWorldtoUdemy.h”

Also, add the following code lines to the didFinishLaunchingWithOptions: method:

 HelloWorldtoUdemy *viewController = [[HelloWorldtoUdemy alloc] initWithNibName:@"HelloWorldtoUdemy " bundle:nil]; self.window.rootViewController = viewController;

Now, if you try to run the application, it will display the button. But, after you tap it, nothing will happen. This is because we are yet to provide code for displaying Hello World on tapping the button.

  1. From the Project Navigator, open the “HelloWorldtoUdemy.h” file. Before the @end line, add the following code lines.

 Now, open the “HelloWorldtoUdemy.m” file, and the following code lines before @end line.

 - (IBAction)showMessage
// Displays the Hello World Message
UIAlertView *helloWorldAlert = [[UIAlertView alloc] initWithTitle:@"My First App" message:@"Hello, World!" delegate:nil cancelButtonTitle:@"OK" otherButtonTitles:nil];  
[helloWorldAlert show]; 
  1. Next, we need to connect this action for displaying message and the button. This will be done in the Interface Builder. Open the “HelloWorldtoUdemy.xib” file. Drag the “Hello World” button from the viewer and drop it to the “File’s Owner” folder in the Project Navigator. A pop-up is displayed. Select the “showMessage” action highlighted in the pop-up to make the connection.

You are done with creating the basic Hello World application. Now, we need to test this app.

Testing your application

Generally, testing on actual devices ensure that you are correct with the layout and no buttons are oversized or undersized. But, the difference that Xcode provides is that the views provided are customized to iPhone and other iOS devices. So, you can select the view before you go ahead with creating the application. In our case, you need to click the “Run” button in the IDE and the view with the “Hello World” button should be displayed. After you click “Ok”, the “Hello World” message is displayed.

 Want to create more intuitive iOS apps? Take a tutorial at Udemy.com.