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