user793789 user793789 - 10 months ago 71
Swift Question

Siesta Swift Casting from ImplicitlyUnwrappedOptional<Swift.AnyObject> to Array<AnyObject>

I am configuring ResponseTransformer of siesta to return array of objects.

service.configureTransformer("/models/*") {

but somehow when I try to convert them to back to array using
let objects = response.content as! [Object]
I got this exception
Could not cast value of type 'Swift.ImplicitlyUnwrappedOptional<Swift.AnyObject>' (0x382a0a0) to 'Swift.Array<Object>' (0x16f5358).


You need to map your response, like this

configureTransformer("/models/*") {

And to get later, you can try this way

let objects = resource.typedContent() ?? []