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