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 twoSum(_ nums: [Int], _ target: Int) -> [Int] { | |
| // Iterate through every element in numbers | |
| for (i, number1) in numbers.enumerated() { | |
| /** | |
| For every iteration, | |
| iterate through numbers, | |
| where i does not equal j. | |
| */ | |
| for (j, number2) in numbers.enumerated() where i != j { | |
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 UIKit | |
| import MapKit | |
| class ViewController: UIViewController { | |
| // - Outlets | |
| @IBOutlet weak var locationLabel: UILabel! | |
| @IBOutlet weak var mapView: MKMapView! |
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: - Get Location | |
| extension LocationManager { | |
| func getLocation(forPlaceCalled name: String, | |
| completion: @escaping(CLLocation?) -> Void) { | |
| let geocoder = CLGeocoder() | |
| geocoder.geocodeAddressString(name) { placemarks, error in | |
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
| class ViewController: UIViewController { | |
| // - Outlets | |
| @IBOutlet weak var locationLabel: UILabel! | |
| // - Constants | |
| private let locationManager = LocationManager() | |
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
| class LocationManager: NSObject { | |
| // - Private | |
| private let locationManager = CLLocationManager() | |
| // - API | |
| public var exposedLocation: CLLocation? { | |
| return self.locationManager.location |
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: - Get Placemark | |
| extension LocationManager { | |
| func getPlace(for location: CLLocation, | |
| completion: @escaping (CLPlacemark?) -> Void) { | |
| let geocoder = CLGeocoder() | |
| geocoder.reverseGeocodeLocation(location) { placemarks, error in | |
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 CoreLocation | |
| class LocationManager: NSObject { | |
| private let locationManager = CLLocationManager() | |
| override init() { |
NewerOlder