0

我正在制作的 iOS 应用程序中有多个模拟数据库。我需要其中一个能够在已经可变的数组中拥有一个可变数组。基本上,我有所谓的 BlockParties,在这些 BlockParty 对象中,我需要一个卡车列表作为 BlockParty 的属性之一。

我的代码目前看起来像这样用于初始化模拟数据库:

 //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; 

我需要 listOfTrucks 属性作为我可以为每个 BlockParty 拥有多辆卡车的可变数组的地方。有任何想法吗?

4

1 回答 1

1
   NSMutableArray *lot = [[ NSMutableArray alloc ] initWithObjects: @"18-Wheeler", @"Dodge-Ram", @"GraveDigger" ];
   NSMutableArray *lot2 = [[ NSMutableArray alloc ] initWithObjects: @"ShagginWagon", @"1984 F250", @"Beer Truck" ];

   listParty = [[NSArray alloc] initWithObjects:
         [BlockParty blockpartyWithName:@"Westside Food Truck Central" listOfTrucks: lot  latitude: [NSNumber numberWithDouble:200.1] longitude: [NSNumber numberWithDouble: 146.5] schedule:@"7/15/12" ],
         [BlockParty blockpartyWithName:@"Venice Food Truck Paradise" listOfTrucks:lot2 latitude:nil longitude:nil schedule:nil], 
        nil];
于 2012-04-18T15:44:53.847 回答