chrisdhaan / CDYelpFusionKit

An extensive Swift wrapper for the Yelp Fusion API.
MIT License
54 stars 18 forks source link

Response object returning nil #13

Closed kbunarjo closed 6 years ago

kbunarjo commented 6 years ago

I tried to create a search request doing the following:

let location = "Washington DC"
let term = "Bars"
let yelpAPIClient = CDYelpAPIClient(apiKey: yelpAppSecret) // yelpAppSecret is the API Key
        yelpAPIClient.searchBusinesses(byTerm: term, location: location, latitude: nil, longitude: nil, radius: nil, categories: nil, locale: nil, limit: 50, offset: nil, sortBy: nil, priceTiers: nil, openNow: nil, openAt: nil, attributes: nil) { (response) in
}

What did you expect to happen?

I expected that the response object have something in its contents.

What happened instead?

The response object was nil. Furthermore, I got this error message in the console: searchBusinesses(byTerm) failure: cancelled. However, I ran this project multiple times and there was once where the search request actually went through. Nothing about the code was different that time, but I was debugging so I had set a couple breakpoints. I haven't been able to replicate the time it worked though.

CDYelpFusionKit Environment

CDYelpFusionKit version: 1.5.0 Xcode version: 9.4.1 **Swift version: Swift 4.1

AndrewDennistoun commented 4 years ago

Hey Kevin, did you end up solving this? The same thing is happening for me and I haven't yet figured it out.

AndrewDennistoun commented 4 years ago

Never mind I figured it out, I was trying to access the client before it was finished initializing. I ended up creating this class from the example and then initializing the client in the AppDelegate (again like the example) and now it seems to be working.