Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Register | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
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 tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Reply
 
Thread Tools Display Modes
  #1 (permalink)  
Old July 1st, 2012, 09:51 AM
Registered User
Points: 5, Level: 1
Points: 5, Level: 1 Points: 5, Level: 1 Points: 5, Level: 1
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
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?
Reply With Quote
  #2 (permalink)  
Old July 2nd, 2012, 12:28 PM
Friend of Wrox
Points: 1,671, Level: 16
Points: 1,671, Level: 16 Points: 1,671, Level: 16 Points: 1,671, Level: 16
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
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
Reply With Quote
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off

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



All times are GMT -4. The time now is 06:32 AM.


Powered by vBulletin®
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.