Skip to content

Instantly share code, notes, and snippets.

extension Array where Element: Identifiable {
public subscript(id: Element.ID) -> Element? {
first { $0.id == id }
}
}
// let arrayOfIdentifiables = []
// let itemWithId = arrayOfIdentifiables[id]
@freak4pc
freak4pc / MKMultiPoint+Ext.swift
Last active September 5, 2024 06:36
Get a list of coordinates from a MKPolyline / MKRoute
public extension MKMultiPoint {
var coordinates: [CLLocationCoordinate2D] {
var coords = [CLLocationCoordinate2D](repeating: kCLLocationCoordinate2DInvalid,
count: pointCount)
getCoordinates(&coords, range: NSRange(location: 0, length: pointCount))
return coords
}
}