title: Post Array to firebase Database in Swift
body: <p><strong>Question</strong>
  <br> I need to post data into the firebase database, which (in terms of arrays) can only accept type <code>NSArray</code>. The application however, needs to add to the array</p>
  
  <p><strong>Json Data that wil be posted</strong></p>
  
  <pre><code>Object: someObjectKey[
    ArrayOfItems[
      Item: someItemNumber
      Item: someItemNumber
      Item: someItemNumber
    ]
    TimeStamp: 102047355
    SomeOtherTimeStamp: null
    SomeInt: 1111
    someOtherInt: 2222
    SomeBoolean: false
    ]
  }
  </code></pre>
  
  <p><strong>Goal</strong>
  <br>How can I get the data above to be pushed up into the database?</p>
  
  <p><strong>Attempted Avenues</strong>
  <br>-Convert a <code>SwiftArray</code> to a <code>NSArray</code>
  <br>-Convert an <code>NSMutableArray</code> to a <code>NSArray</code></p>
  
  <p><strong>Code</strong></p>
  
  <pre><code>public func postToFireBase(){
  
      var Timestamp: String {
          return "\(NSDate().timeIntervalSince1970 * 1000)"
      }
  
      var someInt = 1111
      var someOtherInt = 2222
      let myArrayOfStuff = convertItemsToNSArray()
  
      let post: [String : Any] = ["timestamp": Timestamp,
                  "someInt": someInt,
                  "someOtherInt": someOtherInt,
                  "items": ItemList]
  
      //Method Call References the FIRDatabase.database.reference.child...
      FirebaseDatabaseService.databaseReference.setValue(post)
  }
  
  private func convertItemsToNSArray() -&gt; NSArray{
      var thisArray: NSMutableArray = []
  
      for item in items{
          thisArray.add(["name": "Foo",
                         "key": "Bar",
                         "someCoolInt": 1234])
      }
      return thisArray
      //This won't work because it's coming back as NSMutableArray anyway
  }
  </code></pre>
  
  <p>Cheers</p>