Objective c 是否可以在iOS中将不同类型的对象添加到收藏夹列表中?

Objective c 是否可以在iOS中将不同类型的对象添加到收藏夹列表中?,objective-c,ios,arrays,Objective C,Ios,Arrays,我在模拟数据库中有一个具有各种属性的卡车列表,在模拟数据库中也有一个具有各种属性的区块各方列表(它们不同于卡车属性)。每个列表在选项卡栏应用程序的两个不同XIB中填充两个不同的UITableView。我有第三个选项卡栏xib用于收藏夹。我希望用户能够点击“将此添加到收藏夹”按钮,以便卡车或街区派对可以被放入收藏夹列表中。有人知道这是怎么可能的吗?如果不是,那么至少我如何才能将卡车添加到收藏夹中 // Initialize the mock database of trucks. listC

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

我可以想到的一种方法是,当选择一行时,从trucks tableview(类)和parties tableview(类)发布一个通知以及对象。然后在Favorites类中,实现该通知消息的观察者,并在收到消息时将对象添加到tableview。

您可以向每个类添加BOOL favorite属性,并在选择“将此添加到收藏夹”时将其设置为“是”。然后,在“收藏夹”选项卡中,获取“收藏夹”属性设置为“是”的所有对象。

卡车和阻塞双方是否都将使用相同类型的单元格在表视图中显示其信息?如果他们被选中,他们是否会推送一个包含更多细节的新控制器?他们都将使用相同类型的单元格,如果他们被点击,他们确实会推送到一个新的视图控制器。卡车和区块各方是如何存储的?我现在是如何拥有它们的:添加了我到目前为止的代码。