aronbalog / Vox

Swift JSON:API client framework
http://jsonapi.org
MIT License
46 stars 19 forks source link

Exception: EXC_BAD_INSTRUCTION When accessing nested relationship #25

Open sadiq81 opened 5 years ago

sadiq81 commented 5 years ago

When trying to access a nested object my app crashes

let baseURL = Environment.backendURL.appendingPathComponent("api")
            let dataSource = DataSource<ProductOfferResource>(strategy: .path(ProductOfferResource.resourceType), client: self.client)

            try! dataSource.fetch()
                    .result({ (document: Document<[ProductOfferResource]>) in
                                let productOffers = document.data
                                observer.onNext(productOffers ?? [])

                                // Causes crash
                                let background = productOffers?[0].design?.background_image?.meta 

                                observer.onCompleted()
                            }, { (error) in
                                observer.onError(error ?? NetworkServiceError.unknown)
                            })

All objects can be found https://gist.github.com/sadiq81/bf0e77a8561049ecd0a105479fc3ff5a

sadiq81 commented 5 years ago

screenshot 2019-02-13 at 12 17 33