iOS Development: Hello World! in Xcode Part 2

This second part in a series on developing your first iOS app using Xcode delves into the code of our “Hello World” application.

In this part of the tutorial, I will be discussing the code showcased in part one of this series (http://www.devshed.com/c/a/Smartphone-Development/iOS-Development-Hello-World-in-Xcode-48394/), as well as the general concepts required to program under iOS.

As was mentioned before, I used Xcode 4.1 to create the test project for our discussion. In this version several items are automatically generated when Xcode creates the project. Our main focus for this article will be the HelloWorldAppTutorialAppDelegate header and code files. First, let us look at the header file generated by Xcode.

 


The first line is  the standard import function  used to make the standard iOS objects available to the object that was generated by Xcode for the the running class of the program. The next line establishes the class that will be running on the device and managing the events of the program. B
   asically, it states the the HelloWorldAppTutorialAppDelegate is being generated and that this class is a subclass of the NSObject class. The next line creates the window that is used throughout the use of the program.

 


Next, is the code file that was generated along with the header file. In this case, the focus will only be on the section of the code that was actually changed in our tutorial. While the other portions of the code are important to application development in iOS, they are not important for the general concepts we are covering in this tutorial. Out main focus is on the didFinishLaunchingWithOptions method.


First, the method creates the area container that the UILabel will be displayed in. While this is not required, there are some uses to using this method such as allowing for borders around the UILabel and specific shading around the label. There are properties available for such customization. The UILabel is then created and its properties setup including the standard “Hello World” message. Finally the UILabel is added to the program window and the window is visible to the user and actions taken within the program by the program will be able to be processed by the program.

Finally, the memory that was used by the label is setup to be released when the application closes. This is required in Object-C because the language does not have a Garbage Collection process to release this memory automatically.

 

[gp-comments width="770" linklove="off" ]

chat sex hikayeleri Ensest hikaye