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 3rd, 2011, 02:22 PM
Friend of Wrox
 
Join Date: Aug 2010
Posts: 298
Thanks: 1
Thanked 62 Times in 60 Posts
Default Chapter 1 SimpleTabBar

A number of editorial issues and a few suggestions.

p. 27 a Transaction class is created and implemented on pp 48-49. It is never used.
p. 29 Bullet point steps 2 and 3 of step 8 are a repeat of bullet point steps 2 and 3 of step 7. Also, unless it is different in older versions of the SDK, step 9 is not necessary, since when the UIViewController is created with a .xib the identity of the ThirdViewController is already correctly assigned to File's Owner.
p. 30 step 12 assigning the ThirdViewController has already been done (re: comment about step 9)
p. 32 step 3 The reference to the FirstViewController class should be SecondViewController class.
p. 33 Step 6 repeats the File>Write Class Files step from step 5. Both the .m and .h files have been opened on step 5. (unless the prior SDK behaved differently)
p. 35 Step 2 - The identity of the ThirdViewController is already set (see above)
p. 36 Step 7 - again - The identity of the ThirdViewController is already set
p. 37 #import "PropertyList.h" should probably be bold since it is an addition not mentioned elsewhere.
p. 40 An NSNumberFormatter is created but not used.
p. 41 Listing 1-33 is wrong. It is a repeat of "FirstViewController.m" and not "SecondViewController.m" as it should be.
p. 43 Got the bold for the "PropertyList.h" this time but @synthesize detailTableView is also an addition that should be bold.

Suggestions

The number formatter can be applied to FirstView and ThirdView
In FirstViewController.m

Code:
-(void)viewWillAppear:(BOOL)animated
{
	NSDictionary *d = [PropertyList readFromArchive:@"Data"];
	 NSNumberFormatter *formatter = [[NSNumberFormatter alloc] init];
	 [formatter setNumberStyle:NSNumberFormatterCurrencyStyle];
	
	if (d != nil) {
		NSNumber *bal = [d objectForKey:@"balance"];
		if (bal != nil) {
			[balanceLabel setText:[formatter stringFromNumber:bal]];
		}else {
//			[balanceLabel setText:@"0"];
			[balanceLabel setText:[formatter stringFromNumber:[NSNumber numberWithFloat:0.0]]];
		}
	}else {
		[balanceLabel setText:[formatter stringFromNumber:[NSNumber numberWithFloat:0.0]]];
		//[balanceLabel setText:@"0"];
	}
	[formatter release];
	[super viewWillAppear:animated];
}
and in ThirdViewController.m

Code:
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
	
	NSNumberFormatter *formatter = [[NSNumberFormatter alloc] init];
	[formatter setNumberStyle:NSNumberFormatterCurrencyStyle];
	
    static NSString *CellIdentifier = @"Cell";
	
	NSString *cellText = @"";
    
    UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
    if (cell == nil) {
        cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier] autorelease];
		[cell setSelectionStyle:UITableViewCellSelectionStyleNone];
    }
	
    
    // Configure the cell...
	switch ([indexPath section]) {
		case 0:
			cellText = [NSString stringWithFormat:@"Deposit #%d = %@",([indexPath row] + 1),[formatter stringFromNumber: [[self deposits] objectAtIndex:[indexPath row]]]];
			break;
		case 1:
			cellText = [NSString stringWithFormat:@"Withdrawal #%d = %@",([indexPath row] + 1),[formatter stringFromNumber:[[self withdrawals] objectAtIndex:[indexPath row]]]];
			break;
	
		default:
			break;
	}
	
	cell.textLabel.text = cellText;
    
    return cell;
}
Also having to switch from the Alphabetic Keyboard every time you wish to enter input is not ideal. The number and decimal pad options do not have return keys, so to keep it simple in SecondViewController.m

Code:
- (BOOL)textFieldShouldBeginEditing:(UITextField *)textField
{
	[textField setKeyboardType:UIKeyboardTypeNumbersAndPunctuation];
	return YES;
}
Also, having to clear the input field every time you wish to enter a value is a little tedious so:

in the -viewWillAppear method of SecondViewController I added

Code:
[amountTextField setClearsOnBeginEditing:YES];
Bob

Last edited by thepianoguy; March 3rd, 2011 at 11:56 PM.. Reason: p.41 changed to FirstViewController.m (not .h) and SecondViewController.m (not .h)
 
Old March 3rd, 2011, 03:25 PM
Wrox Author
 
Join Date: Oct 2010
Posts: 61
Thanks: 0
Thanked 9 Times in 7 Posts
Default

Thanks Bob for your attention to detail and suggestions !

Take Care,
Gene





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.