Developers: Learn a New Programming Language or App Development with Deitel LiveLessons Videos!
s
menu
menu
Login  |  Register  |  Media Kit  |  Press  |  Contact Us  |   Twitter Become a Deitel Fan on Facebook  
Custom Search



Download Code
Examples and
Other Premium
Content for
Registered Users

Login or Register to download this book's code examples and other premium content.

Download Code
Examples and
Other Premium
Content for
Registered Users

iPhone for Programmers: An App-Driven Approach
Now Available!

The practicing programmer’s Deitel® guide to iPhone app development using the iPhone SDK 3.x, Objective-C and Xcode
 
iPhone for Programmers—part of the Deitel Developer Series. This book uses an app-driven approach—each new technology is discussed in the context of 14 fully tested iPhone apps (7700 lines of code), complete with syntax shading, detailed descriptions and sample outputs.
 
“This really is turning into the definitive iPhone book...”—Rik Watson, Senior Software Engineer, Lockheed Martin (Book Reviewer)

“I wish I had this book in my hands when I started developing on the iPhone. What it took me a lot of time and many mistakes to learn, is beautifully explained in a clear, concise style that will take you from zero to publishing your first app in no time.”—Marcantonio Magnarapa, Research & Development on Mobile Platforms, Ogilvy Interactive (Book Reviewer)

“iPhone for Programmers covers a wide variety of iPhone programming topics, including advanced features like the CoreLocation API, video playback and asynchronous network communication.   A particular strength is that it provides badly-needed advice on how to use XCode, how to submit your app to the App Store, how to set your price, and how to deal with many of the other non-programming issues that surround iPhone development.  It also gives a quick start to iPhone programming, showing how to build 14 complete iPhone apps, several of which provide day-to-day usability.  For each app, the book briefly describes the purpose of the app, the Objective-C and Cocoa technologies used to build it, and a detailed line by line walkthrough of the app's source code.  All of the source code and project files are included with the book so that you can compile and test-drive each of the apps as you read along.  iPhone for Programmers fits the bill for any programmer interested in taking up iPhone development.”—Zach Saul, Founder, Retronyms (Book Reviewer and co-creator of "Recorder"—one of the Top 10 selling apps for all of 2008; Zach's other apps include "DopplerPad"an expressive musical instrument designed from the ground up for the touch interface of the iPhone and iPod Touch—and "Seek 'n Spell"an innovative, award-winning outdoor video game. Shop for these and other iPhone Applications at iTunes.com!)

Order print and electronic versions now at Safari® Books Online. Order print versions from Amazon.com.

Please see the Preface and Table of contents links in the left column for more information.

Updates for iOS 4 SDKMinimize

We've posted an updated set of examples based on our iPhone App Development Fundamentals LiveLessons videos, which are available to video subscribers at http://www.SafariBooksOnline.com/. The updated examples are available on this page when you are registered and logged into the site. These updated examples were built in the iPhone SDK 3.1.3.

 

Here are some additional notes from building these updated apps against the iOS4 SDK:

 

For each app, perform the following steps:

  1. Go to Project -> Edit Project Settings
  2. Change Base SDK to iPhone Simulator 4.0.2
  3. Select Project -> Set Active SDK -> Simulator3.
  4. Build project
  5. If the build fails because “There is no SDK with the name or path ___” or “Base SDK not found”, go to Project -> Edit Active Target “__” and change Base SDK. 

Other notes:

Each of the apps built fine after changing the project settings to the 4.0 SDK, with the following exceptions:

  • AddressBook:
    Changed project settings and target setting to the 4.0 SDK. I also needed to change the target settings for AddViewController.xib and ContactViewController.xib because they were accidentally set to iOS 2.0. This is fixed by opening them up in interface builder and clicking Window -> Document Info.
  • RouteTracker
    Built fine after changing the project and target settings to the 4.0 SDK.
  • Favorite Twitter Searches: 
    With iOS SDK 4.1, a couple of people have reported issues with this app after trying the steps above. The app appears with a blank screen. To fix this: Open up MainWindow.xib and select 'Favorite Twitter Searches App Delegate' in the window 'MainWindow.xib'. Next, open the inspector and connect the window outlet to the window object.

We are rebuilding the apps from scratch now using the iOS 4 SDK and will post notes about changes to the app templates and the steps required to build each app as soon as we have them.

 


 

ADDITIONAL INFORMATION FOR THE FLAG QUIZ APP:

Due to a change in the Utility application template, this app will have issues. In 3.2, when a new app was created, MainViewController would get instantiated in the application delegate like so:

 

- (void)applicationDidFinishLaunching:(UIApplication *)application {

 

    MainViewController *aController = [[MainViewController alloc] initWithNibName:@"MainView" bundle:nil];

    self.mainViewController = aController;

    [aController release];

 

    mainViewController.view.frame = [UIScreen mainScreen].applicationFrame;

    [window addSubview:[mainViewController view]];

    [window makeKeyAndVisible];

}

 

In 4.0, the line is removed:

 

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {    

 

    // Override point for customization after application launch.  

 

    // Add the main view controller's view to the window and display.

    [window addSubview:mainViewController.view];

    [window makeKeyAndVisible];

 

    return YES;

}

 

MainViewController is instead instantiated in MainWindow.xib. You'll encounter this problem if you follow the steps that we provided in the Flag Quiz chapter and you're using iOS SDK 4.x. The fix is to either add the missing lines of code to the app delegate, or to add a new MainViewConroller instance to MainWindow.xib (with the appropriate connections).

 


 

UPDATED TIP CALCULATOR APP (IOS 4.2):

The TipCalculator app broke in iOS 4 because of a subtle change Apple made to how UITextFields work. Under iOS 4, when we tell billField to become the first responder (and make the keyboard come up), nothing happens because it has the "User Interaction Enable" property disabled. Previously in iOS 3, this was not the case.

 

The simplest way to make the app work is enable that property (in MainWindow.xib, select billField and open the Inspector. Check "User Interaction Enabled"). However, this will let the user change the cursor in billField manually, which is undesirable.

 

Here are some steps to make TipCalculator work under iOS 4, while still maintaining full functionality:

 

1) Open MainWindow.xib and make a duplicate of the top UITextField and move it to the bottom of the screen. Open the Inspector, and check "User Interaction Enabled" and "Hidden" for the new UITextField.

 

2) In the "Connections" tab of the Inspector, remove the "Editing Changed" connection for the origional UITextField. Also delete the text in the new UITextField.

 

3) Open Controller.h. Add the line

 

IBOutlet UITextField *hiddenField;

 

in the interface declaration.

 

4) In MainWindow.xib, connect the "hiddenField" outlet of "Controller" to the new UITextField.

 

5) Replace Controller.m with the version in the new project that's posted at 

 

http://www.deitel.com/bookresources/iPhoneFP/TipCalculator.zip

 

Basically, the way Tip Calculator previously worked was as follows:

User touches button -> billField modified -> calculateTip: called -> bill total updated -> billField modified -> calculateTip: called again -> method exits because of "toggle" variable.

 

Here's the new flow of execution:

User touches button -> hiddedField modified -> calculateTip: called -> bill total updated -> billField modified.

 

This is a cleaner way of doing things, and as a bonus it doesn't break on iOS 4.

 

 

 

c

 

Discounts on SafariBooksOnline.com subscriptions

foot
Update :: May 29, 2017