Part 1: Is It Your First iPhone App Ever?

Part 1: Is It Your First iPhone App Ever?

I’m currently working on my final project for a Bachelor’s in Graphic Design. During the next couple of months I will be learning how to develop an iPhone app aimed at advertising of brands and products, but as of now the final aim is not important. I will inmerse myself from an almost zero level of app developing knowledge and I will try to document the process to ease my final writing and to, perhaps, serve as a helping guide to some lost soul out there.

INTRODUCING XCODE:

To develop iOS apps you use Xcode, Apple’s first-class integrated development environment (IDE). Xcode provides all the tools needed to design your app’s user interface and write the code that brings it to life. Xcode includes the Instruments analysis tool, iOS Simulator, and the latest Mac OS X and iOS SDKs (a source editor, a graphical user interface editor,…). It employs a single window, called the workspace window, that presents most of the tools you need to develop apps. Within this window you smoothly transition from writing code, to debugging, to designing your user interface.

ROAD MAP:

This road map provides the perfect starting point for iOS app development. I will follow it as my learning process and this rough guide hopes the reader does too. I will point out bits and pieces that were not clear enough, wrong or missing, but I will not copy all of its content (that’s just plain stupid).
https://developer.apple.com/library/ios/#referencelibrary/GettingStarted/RoadMapiOS

INSTALLING:

First of all the road map promts you to the Xcode download and setup. I will assume that everything is clear and properly installed.

ENROLL AS A DEVELOPER:

To be able to deploy to a real device and/or finally publish your app on the app store you’ll have to enroll as a developer and pay the fee.
http://developer.apple.com/programs/ios/

YOUR FIRST APP:

As when learning any language (I mean, as in tongues), we firstly learn common and necessary phrases before we even make any sense out of them or know any grammar. In the same way Apple’s guide approaches a first app tutorial in “Jump right in” that could be hard to understand by a newbie but that I’m sure will be clear as water when the learning map is fully completed.

I will assume the reader follows this “Jump Right In” guide side by side:
Jump Right In

MODEL – VIEW – CONTROLLER

The design pattern MVC defines:
Model: data (such as a to-do item in a calendar app or a shape in a drawing app).
View: how to represent such data.
Controller: how to operate between “Model” and “View”.

BASIC SINGLE VIEW

At this point of the Apple guide you’ll be creating a new project based on the Single View template, running it while it is still empty and looking at some of the basic files of the project like:
main.m – jumps to the UIApplicationMain (main for a graphical interface)
Info.plist – configuration file
MainStoryboard.storyboard – visual implementation. Contains the canvas.

ELEMENTS

The next step is to create the appropriate connections between the view controller on the canvas and the class extension in the implementation file (YourAppViewController.m) in the assistant editor. This will also update the implementation file to support the outlets and actions. To achieve this the graphical way you can ctrl+drag an object from the canvas to the corresponding file into the @interface directive, via the Assistant Editor, but you can always write it in yourself.

In fact, my XCode installation failed to write in both lines of code that were needed, so be sure to check that the autogenerated code is always right before moving on. In my case the result should have been the following, but I was missing the declaration line and had to write it in myself:

– declaration:

- (IBAction)changeGreeting:(id)sender;

– implementation:

- (IBAction)changeGreeting:(id)sender {
}

TEXT FIELD’S DELEGATE

You have one more connection to make in your app: You need to connect the text field to an object that you specify as its delegate. The Text Field delegates on the View Controller the management of the string so that it is sent to the Label when the Button is pressed.

VIEW CONTROLLER

In order to pass a string from the Text Field to the Label, the app will make use of the property userName. Even after having it declared properly I obtained the following error:

HWViewController.h:12:39: warning: property 'userName' requires method 'userName' to be defined - use @synthesize, @dynamic or provide a method implementation

If this is also your case, remember to use @synthesize in the @implementation of the VieController.m file to declare setters and getters.

@synthesize userName;

METHODS:

So that the app actually does what you want, you’ll have to implement the changeGreeting method.

Nick Brandt

Next Article

Nick Brandt