我有一个带有各种属性的模拟数据库中的卡车列表,以及具有各种属性的模拟数据库中的块方列表(它们与卡车属性不同)。每个列表在选项卡栏应用程序中的两个不同的xib中填充两个不同的UITableView。我有第三个标签栏xib为收藏夹。我希望用户能够点击“将此添加到收藏夹”按钮,以便卡车或街区派对可以放入收藏夹列表中。有没有人知道这可能是怎么回事?如果没有,那么至少我怎么能将卡车添加到收藏夹?
// 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;
答案 0 :(得分:1)
我能想到的一种方法是在选择行时,通过卡车tableview(类)和派对tableview(类)发布通知以及对象。然后在您的收藏夹类中,实现该通知消息的观察者,并在收到消息时将该对象添加到您的tableview中。
答案 1 :(得分:0)
您可以为每个类添加BOOL favorite属性,并在选择“Add this to Favorites”时将其设置为YES。然后在“收藏夹”选项卡中,获取将“收藏夹”属性设置为“是”的所有对象。