0

我在一个具有各种属性的模拟数据库中有一个卡车列表,以及一个在具有各种属性的模拟数据库中的区块方列表(它们与卡车属性不同)。每个列表在选项卡栏应用程序的两个不同 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;
4

2 回答 2

1

我能想到的一种方法是在选择一行时发布通知以及来自卡车表格视图(类)和各方表格视图(类)的对象。然后在您的收藏夹类中,实现该通知消息的观察者,并在收到消息时将该对象添加到您的表格视图中。

于 2012-04-18T21:03:43.437 回答
0

You could add a BOOL favorite attribute to each of your classes and set it to YES when you select "Add this to Favorites". Then in your Favorites tab, you fetch all objects that have the favorite attribute set to YES.

于 2012-04-18T21:20:41.040 回答