This may seem rather bizarre, but try this.
Redo the code, but don't add the badge to the Search tab item.
Again, I don't have this book, but the project appears to be identical to the one in the author's previous book. That code was fine back in August, when I did the project, but now has the same issues. The downloaded code can be made to work by deleting the MainWindow.xib then setting it up again (Add File>New File>User Interface>Application XIB, add the Tab Bar Controller make the necessary changes (setting nibs etc) and connections, save and Build & Run). The program, Xcode and Interface Builder can be quit. The project can be reopened edited etc, as long as the badge is not added. Once the badge is added, the assertion failure will occur if the file is closed then reopened in Interface Builder. Fortunately the badge is just window dressing and can added in code if wanted.
Let me know if this solves the problem for you.
Bob
addendum:
add the following to the appDelegate to display the badge and avoid the assertion failure
Code:
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
// Override point for customization after application launch.
NSArray *controllerList = [tabBarController viewControllers];
[[[controllerList objectAtIndex:2] tabBarItem] setBadgeValue:@"5"];
// Add the tab bar controller's view to the window and display.
[self.window addSubview:tabBarController.view];
[self.window makeKeyAndVisible];
return YES;
}
or more encapsulated
In the appDelegate
Code:
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
// Override point for customization after application launch.
NSArray *controllerList = [tabBarController viewControllers];
[[controllerList objectAtIndex:2] initWithNibName:nil bundle:nil];
// Add the tab bar controller's view to the window and display.
[self.window addSubview:tabBarController.view];
[self.window makeKeyAndVisible];
return YES;
}
and in SearchViewController.m
Code:
- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil {
self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
if (self) {
[[self tabBarItem] setBadgeValue:@"5"];
}
return self;
}