Creating a restaurant data manager

We need to create a data manager for our restaurants, but before we do that, we need to update a few things. In Swift 4, we have a more natural way to parse JSON, using what is called Decodable. First, we need to update our RestaurantItem, but before we get into what this code looks like, our RestaurantItem needs to conform to Decodable. Open RestaurantItem and update it to include the following:

class RestaurantItem: NSObject, MKAnnotation, Decodable {  var name: String?  var cuisines:[String] = []  var latitude: Double?  var longitude:Double?  var address:String?  var postalCode:String?  var state:String?  var imageURL:String?   var title: String? {    return name  }   var subtitle: String? { if cuisines.isEmpty { return ...

Get iOS 12 Programming for Beginners - Third Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.