Skip to content

Instantly share code, notes, and snippets.

View satan87's full-sized avatar
🏠
Working from home

nicolas satan87

🏠
Working from home
View GitHub Profile
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) {
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.
if !filters.byAuthorFirstName.isEmpty {
bookFiltered.removeAll(
where: {$0.author.firstName.range(of: filters.byAuthorFirstName, options: .caseInsensitive) == nil})
}
switch filters.byFavorite {
case .favorite:
bookFiltered.removeAll(where: {!$0.favorite})
case .notFavorite:
bookFiltered.removeAll(where: {$0.favorite})
default:
break
}
var bookFiltered = books.filter({ filters.byBeforeYear == 0 || $0.year < filters.byBeforeYear})
// 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:
func filterBooks(books: [Book], by filters: SearchingBook) -> [Book]
enum FavoriteSearch {
case all
case favorite
case notFavorite
}
struct SearchingBook {
var byBeforeYear = 0 //0 meaning do not filter on this
var byFavorite = FavoriteSearch.all
var byAuthorFirstName = ""
}