I have a list of trucks in a mock database with various attributes as well as a list of block parties also in a mock database with various attributes (they are different from the truck attributes). Each of the lists populate two different UITableViews in two different xibs in a tab bar application. I have a third tab bar xib for favorites. I want the ability of users to tap an “Add this to Favorites” button so that either a truck or a block party can be placed into the list of favorites. Does anyone have an idea of how this might be possible? If not, both then at least how would I be able to add the Trucks to the favorites?
// Initialize the mock database of trucks.
listContent = [[NSArray alloc] initWithObjects:
[Truck truckWithCuisine:@"American Cuisine" name:@"Buttermilk Truck" menu:[NSData dataWithContentsOfFile:@"/Users/Steve/Desktop/Truck Tracker App/Truck Tracker App/Buttermilk Truck Menu.tiff"] latitude: [NSNumber numberWithDouble: 0.1] longitude: [NSNumber numberWithDouble: 0.1]schedule:@"7/15/12"],
[Truck truckWithCuisine:@"American Cuisine" name:@"In N Out Burgers" menu:[NSData dataWithContentsOfFile:@"/Users/Steve/Desktop/Truck Tracker App/Truck Tracker App/Lobsta Truck Menu.tiff"]
latitude: [NSNumber numberWithDouble: 23.2] longitude: [NSNumber numberWithDouble: 80.2] schedule: nil],
[Truck truckWithCuisine:@"Mexican Cuisine" name:@"Hacienda Mexican" menu: nil
latitude: [NSNumber numberWithDouble: 42.3] longitude: [NSNumber numberWithDouble: 64.3] schedule: nil],
[Truck truckWithCuisine:@"Indian Cuisine" name:@"Naboo Indian" menu: nil
latitude: [NSNumber numberWithDouble: 0.4] longitude: [NSNumber numberWithDouble: 0.4] schedule: nil],
[Truck truckWithCuisine:@"Italian Cuisine" name:@"Vito's Italian" menu: nil
latitude: [NSNumber numberWithDouble: 33.9698156] longitude: [NSNumber numberWithDouble: -118.4185009] schedule: nil],
nil];
selectedTruck = nil;
NSLog(@"delegate: %d", [listContent count]);
//Initialize the mock database of users.
listPeople = [[NSMutableArray alloc] initWithObjects:
[Person personWithEmail:@"stephen@techgroupintl.com" password:@"test" type:@"User"],
[Person personWithEmail:@"dondi@lmu.edu" password:@"test" type:@"Truck Owner"],
nil];
selectedPerson = nil;
//Initialize the mock database of block parties.
listParty = [[NSArray alloc] initWithObjects:
[BlockParty blockpartyWithName:@"Westside Food Truck Central" listOfTrucks: nil latitude: [NSNumber numberWithDouble:200.1] longitude: [NSNumber numberWithDouble: 146.5] schedule:@"7/15/12" ],
[BlockParty blockpartyWithName:@"Venice Food Truck Paradise" listOfTrucks:nil latitude:nil longitude:nil schedule:nil],
nil];
selectedBlockParty = nil;
One way that I can think of is by posting a notification along with the object from trucks tableview (class) and from the parties tableview (class) when a row is selected. Then in your Favorites class, implement an observer of that notification message and add the object to your tableview when a message is received.