Skip to content

Instantly share code, notes, and snippets.

@quique123
Created January 29, 2011 03:35
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save quique123/801486 to your computer and use it in GitHub Desktop.
Save quique123/801486 to your computer and use it in GitHub Desktop.
List View Controller for Shipments
- (void)save {
AppDelegate_Phone *appDelegate = [[UIApplication sharedApplication] delegate];
NSManagedObjectContext *managedObjectContext = [appDelegate managedObjectContext];
Shipment *newShipment = (Shipment *)[NSEntityDescription insertNewObjectForEntityForName:@"Shipment" inManagedObjectContext:managedObjectContext];
[newShipment setValue:nameTextField.text forKey:shipment.shipperName];
NSError *error = nil;
if (![shipment.managedObjectContext save:&error]) {
NSLog(@"Unresolved error %@, %@", error, [error userInfo]);
abort();
}
NSLog(@"calling rAVC delegate-save");
[self.delegate addShipmentModalVC:self didAddShipment:shipment];
}
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
NSInteger section = indexPath.section;
EditingViewController *nextViewController = [[EditingViewController alloc] initWithNibName:@"EditingViewController" bundle:nil];
//((EditingViewController *)nextViewController).shipment = shipment;
NSLog(@"shipment = %@", shipment);
nextViewController.editedObject = shipment;
switch (section) {
case MONIES_SECTION:
NSLog(@"Monies Selected");
nextViewController.editingDate = NO;
switch (indexPath.row) {
case 1:
nextViewController.editedFieldKey = @"orderAmount";
nextViewController.editedFieldName = NSLocalizedString(@"orderAmount", @"display name for title");
break;
case 2:
nextViewController.editedFieldKey = @"initialWireAmount";
nextViewController.editedFieldName = NSLocalizedString(@"initialWireAmount", @"display name for title");
break;
}
- (void)viewWillAppear:(BOOL)animated {
[super viewWillAppear:animated];
// Configure the user interface according to state.
if (editingDate) {
// make picker visible...
datePicker.alpha = 1;
}
else {
// otherwise hide picker and make textfields visible, or place behind picker :)
datePicker.alpha = 0;
NSLog(@"NO DATE EDITING");
NSLog(@"eFK: %@, eFN: %@",editedFieldKey, editedFieldName);
//textField.text = [editedObject valueForKey:editedFieldKey];
//[textField becomeFirstResponder];
}
}
- (void)addShipment:(id)sender {
AddShipmentModalVC *addController = [[AddShipmentModalVC alloc] initWithNibName:@"AddShipmentModalVC" bundle:nil];
addController.delegate = self;
// Create and configure a new instance of the Shipment entity
Shipment *newShipment = (Shipment *)[NSEntityDescription insertNewObjectForEntityForName:@"Shipment" inManagedObjectContext:managedObjectContext];
addController.shipment = newShipment;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment