Q:

How to store Values in Array/NSMutableArray From Model Class Dictionary? 

Here i want to store values into an Array from ModelClass response Dictionary. 

Model Class Dictionary Function

func toDictionary() -> [String:Any]
    {
        var dictionary = [String:Any]()
        if inwishlist ! = nil{
            dictionary["Inwishlist"] = inwishlist
        }
        if image ! = nil{
            dictionary["image"] = image
        }
        if productId ! = nil{
            dictionary["product_id"] = productId
        }
        if productName ! = nil{
            dictionary["product_name"] = productName
        }
        if regularPrice ! = nil{
            dictionary["regular_price"] = regularPrice
        }
        if shortDescription ! = nil{
            dictionary["short_description"] = shortDescription
        }
        if specialPrice ! = nil{
            dictionary["special_price"] = specialPrice
        }
        if stockStatus ! = nil{
            dictionary["stock_status"] = stockStatus
        }
        if type ! = nil{
            dictionary["type"] = type
        }
        if wishlistItemId ! = nil{
            dictionary["wishlist_item_id"] = wishlistItemId
        }
        return dictionary
    }

Response i get from API

 "products" : [
      {
        "special_price" : "",
        "stock_status" : true,
        "product_id" : "879",
        "type" : "simple",
        "image" : "catalog\/product\/k\/8\/k834_8.jpg",
        "product_name" : "Bourgeat Stainless Steel Saucepan Lid 240mm",
        "regular_price" : "17.4900",
        "wishlist_item_id" : "0",
        "Inwishlist" : "OUT",
        "short_description" : null
      }    

    ]

But when I try This code :-
let dataS = self.resultGetProductRoot?.response.products[0].toDictionary().keys as! [ String]

i get this error:-

Cast from 'Dictionary. Keys?'  to unrelated type '[String]' always fails   

And when I try This code :-
  let dataS = self.resultGetProductRoot?.response.products[0].toDictionary().keys
  var dat = [String]()
  dat = dataS

i got below error:-  

Cannot assign value of type 'Dictionary. Keys?'  to type '[String]'

A:

Since Xcode 7.0 beta 6 in order to have the keys of your Dictionary as an array you can achieve it like this:
let productKeys = self.resultGetProductRoot?.response.products[0].toDictionary().keys
var productKeysList = Array(productKeys)

