Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class Place {
- var placeID: String?
- var title: String?
- var vicinity: String?
- var detailsUrl: String?
- var openingHours: OpeningHours?
- var position: [Double]
- var coordinate: CLLocationCoordinate2D {
- return CLLocationCoordinate2DMake(position.first ?? 0, position.last ?? 0)
- }
- extension Array {
- func removingDuplicates <T: Hashable>(byKey key: (Element) -> T) -> [Element] {
- var result = [Element]()
- var seen = Set<T>()
- for value in self {
- if seen.insert(key(value)).inserted {
- result.append(value)
- }
- }
- return result
- }
- }
- let array = list.removingDuplicates(byKey: { "($0.coordinate.latitude)" + "($0.coordinate.longitude)" + ($0.title ?? " ") + ($0.vicinity ?? " ") })
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement