Essentially I have the following function:
func stagedCount() {
let url = "example.com"
let parameters: Parameters =
["person": "\(name)"]
Alamofire.request(url, method: .post, parameters: parameters).responseData(completionHandler : { response in
if let allObjects = response.result.value as? NSArray{
print("Array length is \(allObjects.count)")
}
}
)}
The JSON response from the URL looks like this:
[
{
"person": "Jake",
"hobby": "soccer"
},
{
"person": "Mary",
"hobby": "surfing"
}
]
I am getting the following response and no count is currently printing.
Cast from 'Data?' to unrelated type 'NSArray' always fails
How can I fix this to get a count of the amount of records in the array? The result I am looking for is 2