BNRAppDelegate

When Xcode created your project via the Empty Application template, it created one class for you: BNRAppDelegate. Your app delegate is the starting point of your application, and every iOS application has one. The single instance of BNRAppDelegate is responsible for processing events and coordinating the work of other objects in the application.

Open BNRAppDelegate.h. Add four instance variables and an instance method. The first three instance variables are pointers to objects that the user can see and interact with – a table view that will display all the tasks to be done, a text field where you can enter a new task, and a button that will add the new task to the table. The fourth object is a mutable array. This is where you will store the tasks as strings.

#​i​m​p​o​r​t​ ​<​U​I​K​i​t​/​U​I​K​i​t​.​h​>​

@​i​n​t​e​r​f​a​c​e​ ​B​N​R​A​p​p​D​e​l​e​g​a​t​e​ ​:​ ​U​I​R​e​s​p​o​n​d​e​r​
<​U​I​A​p​p​l​i​c​a​t​i​o​n​D​e​l​e​g​a​t​e​>​
{​
 ​ ​ ​ ​U​I​T​a​b​l​e​V​i​e​w​ ​*​t​a​s​k​T​a​b​l​e​;​
 ​ ​ ​ ​U​I​T​e​x​t​F​i​e​l​d​ ​*​t​a​s​k​F​i​e​l​d​;​
 ​ ​ ​ ​U​I​B​u​t​t​o​n​ ​*​i​n​s​e​r​t​B​u​t​t​o​n​;​

 ​ ​ ​ ​N​S​M​u​t​a​b​l​e​A​r​r​a​y​ ​*​t​a​s​k​s​;​
}​

-​ ​(​v​o​i​d​)​a​d​d​T​a​s​k​:​(​i​d​)​s​e​n​d​e​r​;​

@​p​r​o​p​e​r​t​y​ ​(​s​t​r​o​n​g​,​ ​n​o​n​a​t​o​m​i​c​)​ ​U​I​W​i​n​d​o​w​ ​*​w​i​n​d​o​w​;​

@​e​n​d​

Notice that the file UIKit.h was imported by the template. UIKit is the framework that contains most of the iOS-specific classes, like UITableView, UITextField, and UIButton. In addition, BNRAppDelegate conforms to the UIApplicationDelegate protocol.

Note that we don’t import Foundation.h. How then can we use NSMutableArray? In this template, the Foundation framework header is part of the precompiled header file for this project, so Foundation classes are available to use. (Don’t believe me? Click on iTahDoodle-Prefix.pch under Supporting Files in the project navigator and see for yourself.)

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset