This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import Foundation | |
| import MapKit | |
| final class MapKitService { | |
| // Map the Apple Category to your own category | |
| private let typesToDrink: [MKPointOfInterestCategory] = [.brewery, .cafe, .winery] | |
| private let typesToEat: [MKPointOfInterestCategory] = [.foodMarket, .restaurant] | |
| func retrieve(from: String, completionBlock: @escaping ([Place]) -> Void) { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| MapKit | GooglePlace | Winner | ||
|---|---|---|---|---|
| Installation | Embedded in iOS | Registration + Pod | MapKit |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| switch filters.byFavorite { | |
| case .favorite: | |
| bookFiltered.removeAll(where: {!$0.favorite}) | |
| case .notFavorite: | |
| bookFiltered.removeAll(where: {$0.favorite}) | |
| default: | |
| break | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| var bookFiltered = books.filter({ filters.byBeforeYear == 0 || $0.year < filters.byBeforeYear}) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // MARK: FILTER FUNCTION | |
| func filterBooks(books: [Book], by filters: SearchingBook) -> [Book]{ | |
| var bookFiltered = books.filter({ filters.byBeforeYear == 0 || $0.year < filters.byBeforeYear}) | |
| //Search by favorite | |
| switch filters.byFavorite { | |
| case .favorite: | |
| bookFiltered.removeAll(where: {!$0.favorite}) | |
| case .notFavorite: |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| func filterBooks(books: [Book], by filters: SearchingBook) -> [Book] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| enum FavoriteSearch { | |
| case all | |
| case favorite | |
| case notFavorite | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| struct SearchingBook { | |
| var byBeforeYear = 0 //0 meaning do not filter on this | |
| var byFavorite = FavoriteSearch.all | |
| var byAuthorFirstName = "" | |
| } |