Wrox Programmer Forums
|
BOOK: Beginning iOS 5 Application Development
This is the forum to discuss the Wrox book Beginning iOS 5 Application Development by Wei-Meng Lee; ISBN: 978-1-1181-4425-1
Welcome to the p2p.wrox.com Forums.

You are currently viewing the BOOK: Beginning iOS 5 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 July 1st, 2012, 09:51 AM
Registered User
 
Join Date: Jul 2012
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Default Compatible with iOS 5.1?

Hi
Is this book compatible with iOS 5.1 and XCode 4.3.3? I have come across a few problems so far but have seen those are errata after reading posts here. I have now hit a problem though in Chapter 4 where some of the code generated for MasterDetail does not match the code in the tutorial code, specifically the If Statement in ViewDidLoad under [super viewDidLoad]. The code which is generated is:

self.navigationItem.leftBarButtonItem = self.editButtonItem;

UIBarButtonItem *addButton = [[[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemA dd target:self action:@selector(insertNewObject:)] autorelease];
self.navigationItem.rightBarButtonItem = addButton;

I tried commenting this out and replacing with the code from the book but just got different errors instead.

Any ideas?
 
Old July 2nd, 2012, 12:28 PM
Friend of Wrox
 
Join Date: Aug 2010
Posts: 298
Thanks: 1
Thanked 62 Times in 60 Posts
Default

The project should work fine in the current Xcode and iOS release. (I did not check it with the iOS 6 beta)

The template for the MasterDetail project changed and the author did not update the project to reflect these changes. You can comment out the code
Code:
    self.navigationItem.leftBarButtonItem = self.editButtonItem;

    UIBarButtonItem *addButton = [[[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemAdd target:self action:@selector(insertNewObject:)] autorelease];
    self.navigationItem.rightBarButtonItem = addButton;
since this is not used.
If you try to copy the books code directly (I don't have the book, but am referring to the downloadable project), assuming all of your classes are named as in the book, you should have no problems. One line is redundant since the assignment is handled in the AppDelegate class.
Code:
self.detailViewController = 
        (MasterDetailDetailViewController *) [[self.splitViewController.viewControllers lastObject] topViewController];
can be omitted since the assignment is done in the AppDelegate's
Code:
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
method.

the complete -viewDidLoad would be

Code:
    - (void)viewDidLoad
{
    [super viewDidLoad];
    //—-initialize the array—-
    listOfMovies = [[NSMutableArray alloc] init];[listOfMovies addObject:@"Training Day"];[listOfMovies addObject:@"Remember the Titans"];[listOfMovies addObject:@"John Q."];[listOfMovies addObject:@"The Bone Collector"];[listOfMovies addObject:@"Ricochet"];[listOfMovies addObject:@"The Siege"];[listOfMovies addObject:@"Malcolm X"];[listOfMovies addObject:@"Antwone Fisher"];[listOfMovies addObject:@"Courage Under Fire"];[listOfMovies addObject:@"He Got Game"];[listOfMovies addObject:@"The Pelican Brief"];[listOfMovies addObject:@"Glory"];[listOfMovies addObject:@"The Preacher’s Wife"];
    
    self.navigationItem.title = NSLocalizedString(@"Movies", @"Movies");
    //---
    if ([[UIDevice currentDevice] userInterfaceIdiom] == UIUserInterfaceIdiomPad) {
        [self.tableView selectRowAtIndexPath:[NSIndexPath indexPathForRow:0 inSection:0] animated:NO scrollPosition:UITableViewScrollPositionMiddle];
    }
    //---
	// Do any additional setup after loading the view, typically from a nib.
//    self.navigationItem.leftBarButtonItem = self.editButtonItem;
//
//    UIBarButtonItem *addButton = [[[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemAdd target:self action:@selector(insertNewObject:)] autorelease];
//    self.navigationItem.rightBarButtonItem = addButton;
}
    }
Of course the commented out lines can just be deleted.

One problem with this (for me) is the fact that the author has the tableView select a row, without having the detailView reflect the selection. A better approach would be

Code:
    if ([[UIDevice currentDevice] userInterfaceIdiom] == UIUserInterfaceIdiomPad) {
        [self.tableView selectRowAtIndexPath:[NSIndexPath indexPathForRow:0 inSection:0] animated:NO scrollPosition:UITableViewScrollPositionMiddle];
        //---
        [self.tableView.delegate tableView:self.tableView didSelectRowAtIndexPath:[NSIndexPath indexPathForRow:0 inSection:0]];
    }
If you have further problems, be specific about what errors are being generated, and your issues should be able to be sorted out.


Bob





Similar Threads
Thread Thread Starter Forum Replies Last Post
Beginning iOS 4 App Dev pg 90 Addview remitdlo Xcode 1 October 30th, 2011 08:45 AM
Beginning IOS 4 Development Chapter 2 webslinger2011 BOOK: Beginning iOS 4 Application Development 1 July 21st, 2011 05:35 PM
Code Compatible with PHP 5.3? cantera25 BOOK: Professional PHP Design Patterns 1 July 1st, 2011 09:06 AM
working with iOS 4 adtomix BOOK: Beginning iOS 4 Application Development 2 June 8th, 2011 12:50 PM
How to change the Base SDK of your iOS project weimenglee BOOK: Beginning iOS 4 Application Development 0 May 17th, 2011 10:07 PM





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