Wrox Programmer Forums
|
BOOK: Professional iPhone and iPad Application Development
This is the forum to discuss the Wrox book Professional iPhone and iPad Application Development by Gene Backlin; ISBN: 978-0-470-87819-4
Welcome to the p2p.wrox.com Forums.

You are currently viewing the BOOK: Professional iPhone and iPad Application Development section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old March 15th, 2011, 12:53 PM
Friend of Wrox
 
Join Date: Aug 2010
Posts: 298
Thanks: 1
Thanked 62 Times in 60 Posts
Default Chapter 6

The LocalNamedNotification project presents a conflict between the colors for the background, with the appDelegate coding for red and blue and the .xib and controller files going with black and white. Easy to catch but obviously they need to match.

Also a style preference - I like setting global variables for the user defined notification constants to take advantage of autofill, and to prevent mistyping the notification name (can't imagine who would do that! I think I have a built in routine [self mistypeNotificationName];)

This is what I did, adding a prefix from the title of the program:

In the …Controller.h file

Code:
#import <UIKit/UIKit.h>


extern NSString * const  LNNSetImageBackgroundRed;
extern NSString * const  LNNSetImageBackgroundBlue;


@interface LocalNamedNotification_iPhoneViewController : UIViewController {
and in the …Controller.m file

Code:
#import "LocalNamedNotification_iPhoneViewController.h"


NSString * const  LNNSetImageBackgroundRed = @"setImageBackgroundRed";
NSString * const  LNNSetImageBackgroundBlue = @"setImageBackgroundBlue";

@implementation LocalNamedNotification_iPhoneViewController
so in the …AppDelegate.m file the registration would be
Code:
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
    // Override point for customization after application launch.
    [[NSNotificationCenter defaultCenter] addObserver:self
                                             selector:@selector(setImageBackgroundRed:)
                                                 name:LNNSetImageBackgroundRed
                                               object:nil];
    [[NSNotificationCenter defaultCenter] addObserver:self
                                             selector:@selector(setImageBackgroundBlue:)
                                                 name:LNNSetImageBackgroundBlue
                                               object:nil];
    
    self.window.rootViewController = self.viewController;
    [self.window makeKeyAndVisible];
    return YES;
}
with the string constant used consistently for the notification name in all other relevant places.

Bob
 
Old March 15th, 2011, 01:41 PM
Wrox Author
 
Join Date: Oct 2010
Posts: 61
Thanks: 0
Thanked 9 Times in 7 Posts
Default

Hey Bob,

They originally matched, then at the end in Author Review, it was brought to my attention that the book was not going to be in color, so I have to change to black and white.





Similar Threads
Thread Thread Starter Forum Replies Last Post
Chapter 6 - Code Download Missing for this Chapter dbaechtel BOOK: Professional SharePoint 2007 Development ISBN: 978-0-470-11756-9 0 August 11th, 2009 11:02 AM
Chapter 2 - End of chapter exercises whizzkid1892 BOOK: Beginning PHP5, Apache, and MySQL Web Development ISBN: 978-0-7645-7966-0 1 July 30th, 2008 12:02 PM
Generics chapter 12 difficult chapter i found ...? Larryz C# 2005 1 July 4th, 2007 09:40 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.