How do you capture the Add New City data when trying to make the CityGuide program from the iOS programming second edition book in Chapter 5?

How do you capture the Add New City data when trying to make the CityGuide program from the iOS programming second edition book in Chapter 5?
1 person has
this question
+1
Reply
  • Tai Hake (Official Rep) May 15, 2012 19:21
    Hello,
    that's a great question for one of our book tech staff to look into. I'll get your question over to them to review.
    You can reach them directly for any other questions you may have about the book at:
    booktech@oreilly.com

    Cheers
    Tai H.
    Customer Service Rep,
    O'Reilly Media
  • (some HTML allowed)
    How does this make you feel?
    Add Image
    I'm

    e.g. kidding, amused, unsure, silly sad, anxious, confused, frustrated indifferent, undecided, unconcerned happy, confident, thankful, excited

  • Unless I've misunderstood the question, the "Add New City..." interface is added to the application from p.102 onwards, the actual capture of the information in this interface is added as the saveCity: method detailed on p.110 which is added to the AddCityController view controller. This method inserts a new city into the UITableView of the CGViewController.

    - (void)saveCity:(id)sender {
    CGAppDelegate *delegate = (CGAppDelegate *)[[UIApplication sharedApplication] delegate];
     NSMutableArray *cities = delegate.cities;
    UITextField *nameEntry = (UITextField *)[nameCell viewWithTag:777];
    UITextView *descriptionEntry = (UITextView *)[descriptionCell viewWithTag:777];

    if ( nameEntry.text.length > 0 ) {
    City *newCity = [[City alloc] init];
    newCity.cityName = nameEntry.text;
    newCity.cityDescription = descriptionEntry.text;
    newCity.cityPicture = nil;
    [cities addObject:newCity];
    CGViewController *viewController = delegate.viewController;
    [viewController.tableView reloadData];
    }
    [delegate.navController popViewControllerAnimated:YES];
    }


    Cheers,
    Alasdair.
    The author of "Learning iOS Programming"

    PS. Page numbers refer to the printed edition.
  • (some HTML allowed)
    How does this make you feel?
    Add Image
    I'm

    e.g. kidding, amused, unsure, silly sad, anxious, confused, frustrated indifferent, undecided, unconcerned happy, confident, thankful, excited