lundi 13 février 2017

Downcasting an array from a server that's of type "Any" to a type NSArray ruins the order of the array

Vote count: 0

So I'm grabbing an array from my server, which is given to me automatically as type Any. As soon as I downcast it to further manipulate it, the order gets completely messed up. This is terrible as there is a ton of elements in that array, and sorting it takes a perceivable amount of time. Essentially what I have is this

 let dataFromServer = data .    //type Any

 print (dataFromServer) // [1, 2, 3, 4]

  let dataFromServer = data as! [Int] 
  print (dataFromServer) // [4, 2, 1, 3]

I wouldn't be complaining if it was 4 elements. But its thousands of elements that need to be sorted everytime. Well I guess what I'm trying to ask is, is there possibly a workaround for this.

asked 17 secs ago

Let's block ads! (Why?)



Downcasting an array from a server that's of type "Any" to a type NSArray ruins the order of the array

Aucun commentaire:

Enregistrer un commentaire