title: Create an array of Struct arrays?
body: <p>I have a query that builds a Struct array from some objects.  I want to append multiple of these structs into a single array so that i can use it populate a collectionview that is nested inside a collectionview.  Im not sure this is the best idea but its all I've got a the moment.</p>
  
  <p>So my Struct is:</p>
  
  <pre><code>struct CollectionStruct {
      var name : String
      var description : String
      var title : String
      var image : PFFile
      var id: String
  }
  </code></pre>
  
  <p>In my viewcontroller the variable to hold the struct is thus:</p>
  
  <pre><code>var packArray : [CollectionStruct] = []
  var partArray : [CollectionStruct] = []
  
  var packId = ""
  </code></pre>
  
  <p>So below what I'm doing is using an item of the previously created packArray to query the DB and build my partArray.  Because i want to do this multiple times and append the partArray into a larger parent array i was thinking of using a for loop like:</p>
  
  <pre><code>var i  = 0
  
  for item in self.packArray as [AnyObject] {
  
      self.packId = self.packArray[i].id
  
          BuildArray.buildArrayFromQuery(queryForCollection: "Part", selectedPackID: self.packId, delegateSender: "DownloadPart", completeBlock: { (result) in
  
              self.partArray = result
  
              // append this to an array of partArray????
  
          })
  }
  </code></pre>
  
  <p>I don't even know where to start with this.  Is it a bad idea?</p>
  
  <p>essentially what i thought was to call this parent array in cellforitem maybe something like:</p>
  
  <pre><code>innerCell.imageCell.image = parentArray[indexPath.item].partArray[indexPath.item].image
  </code></pre>
  
  <p>but i could be way off.</p>
  
  <p>----- EDIT -----</p>
  
  <p>so i can use a multidimensional array inside the closure once self.partArray is set:</p>
  
  <pre><code>self.partArray = result
      var parentArray = [[self.partArray]]
          parentArray.append([self.partArray])
  </code></pre>
  
  <p>but this is unusable outside the closure.  How to declare this multidimensional array before self.partArray is set?</p>
  
  <p>------- EDIT -------</p>
  
  <p>Looking into globals for this at the moment.</p>
  
  <pre><code>class GlobalPartArray {
      private init() { }
      static let sharedInstance = GlobalPartArray()
      var globalPartArray = [CollectionStruct]()
  }
  class GlobalParentArray {
      private init() { }
      static let sharedInstance = GlobalParentArray()
      var globalParentArray = [[GlobalPartArray]]()
  }
  </code></pre>
  
  <p>then inside closure:</p>
  
  <pre><code>GlobalPartArray.sharedInstance.globalPartArray = result
        //can not convert [CollectionStruct] to [GlobalPartArray]
  GlobalParentArray.sharedInstance.globalParentArray.append(GlobalPartArray.sharedInstance.globalPartArray)
  </code></pre>
  
  <p>but it throws an error when trying to convert.  I obviously need to convert this data somehow before appending to the GlobalParentArray.</p>