Created
January 29, 2011 03:35
-
-
Save quique123/801486 to your computer and use it in GitHub Desktop.
List View Controller for Shipments
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
- (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]; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
- (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; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
- (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]; | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
- (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