How do I use the Yelp API in Swift?

I don't know Objective-C. They don't have sample code on their page for Swift. Has anyone used their new V2 API with Swift that can provide some examples or simple searches like asking for local restaurants nearby and more importantly how to provide their required keys?

+3


source to share


1 answer


Try this: https://github.com/codepath/ios_yelp_swift



Yelp main client

This is a headless example of how to implement the OAuth 1.0a Yelp client API. The Yelp API provides an application token that allows applications to make unauthorized requests to their search API.

Next steps

Check out BusinessesViewController.swift to learn how to use the Business Model. Request example

Basic search with query

Business.searchWithTerm("Thai", completion: { (businesses: [Business]!, error: NSError!) -> Void in
    self.businesses = businesses

    for business in businesses {
        print(business.name!)
        print(business.address!)
    }
})

      

Advanced search using categories, sorting and filtering deals

Business.searchWithTerm("Restaurants", sort: .Distance, categories: ["asianfusion", "burgers"], deals: true) { (businesses: [Business]!, error: NSError!) -> Void in

    for business in businesses {
        print(business.name!)
        print(business.address!)
    }
}

      

0


source







All Articles