Database Reference
In-Depth Information
Building the Foundation of the App
We will create a simple app that displays a welcome message on the main screen. Inside the Utility
Screen there are text fields the user can edit and save. The fields will be saved in the user defaults
for the app as well as iCloud. Let's start by building the app without iCloud support.
Organization and Preliminary Setup
In this app we access some methods from the Application Delegate. We create a Define Directive in
the precompiled headers file to make this process easier to use later. This is something done in all
the apps built and using a shorthand method helps move things along faster.
Rename the AppDelegate.h and AppDelegate.m file to CTAppDelegate.h and
CTAppDelegate.m , respectively. You can do this by selecting the file in the
Project Navigator and then selecting it again.
1.
Now let's select the CTAppDelegate.h file and change the comment on line 2
from AppDelegate.h to CTAppDelegate.h .
2.
We also want to change the class name on line 11 from AppDelegate to
CTAppDelegate .
3.
#import <UIKit/UIKit.h>
@interface CTAppDelegate : UIResponder <UIApplicationDelegate>
Select the CTAppDelegate.m file and change the comment on line 2 from
AppDelegate.m to CTAppDelegate.m .
4.
Change your import call from #import " AppDelegate.h " to #import
" CTAppDelegate.h " .
5.
Change the class name of the implementation to CTAppDelegate .
6.
#import "CTAppDelegate.h"
#import "MainViewController.h"
@implementation CTAppDelegate
Select the iCloudTestApp-Prefix.pch file. This can be found under the
Supporting Files group.
7.
Just above the last #endif statement add a line and type:
8.
#import "CTAppDelegate.h"
Add two more lines above the #endif statement and type the following:
9.
#define AppDelegate (CTAppDelegate *)[[UIApplication sharedApplication] delegate]
 
Search WWH ::




Custom Search