2012-04-18 4 views
0

나는 내가 만들고있는 나의 IOS 응용 프로그램 내에 여러 모의 데이터베이스를 가지고 있습니다. 이미 변경 가능한 배열 내에서 변경 가능한 배열을 가질 수 있으려면 그 중 하나가 필요합니다. 기본적으로, 나는 BlockParties라고 불리는 것을 가지고 있으며, BlockParty 객체 내에서 Truck의 목록을 BlockParty의 속성 중 하나로 필요로합니다.Objective-C 배열 안에 배열을 넣는 방법

내 코드는 현재 모의 데이터베이스를 초기화하는 다음과 같습니다

//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 여러 트럭의 변경 가능한 배열을 가질 수있는 것으로 속성이 필요합니다. 어떤 아이디어?

+1

무엇이 문제입니까? 이 접근법은 잘 작동합니다. –

+0

다른 모의 데이터베이스의 트럭이 listOfTrucks 내에 있어야합니다. 그것을하는 방법을 모르겠다. 어쩌면 그걸 쓸 수 있을까요? – crashprophet

답변

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]; 
관련 문제