Skip to content

Instantly share code, notes, and snippets.

View davidseek's full-sized avatar
💭
He/Him

David Seek davidseek

💭
He/Him
View GitHub Profile
import Foundation
import CoreLocation
class LocationManager: NSObject {
private let locationManager = CLLocationManager()
override init() {
// MARK: - Get Placemark
extension LocationManager {
func getPlace(for location: CLLocation,
completion: @escaping (CLPlacemark?) -> Void) {
let geocoder = CLGeocoder()
geocoder.reverseGeocodeLocation(location) { placemarks, error in
class LocationManager: NSObject {
// - Private
private let locationManager = CLLocationManager()
// - API
public var exposedLocation: CLLocation? {
return self.locationManager.location
class ViewController: UIViewController {
// - Outlets
@IBOutlet weak var locationLabel: UILabel!
// - Constants
private let locationManager = LocationManager()
// MARK: - Get Location
extension LocationManager {
func getLocation(forPlaceCalled name: String,
completion: @escaping(CLLocation?) -> Void) {
let geocoder = CLGeocoder()
geocoder.geocodeAddressString(name) { placemarks, error in
import UIKit
import MapKit
class ViewController: UIViewController {
// - Outlets
@IBOutlet weak var locationLabel: UILabel!
@IBOutlet weak var mapView: MKMapView!
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 {
func twoSum(_ nums: [Int], _ target: Int) -> [Int] {
/**
Init an empty dictionary.
The value will be the array element.
The key will be the index of the element.
*/
var hashMap: [Int: Int] = [:]
// Iterate through every element in numbers
for (i, element) in numbers.enumerated() {
func addTwoNumbers(_ l1: ListNode?, _ l2: ListNode?) -> ListNode? {
// Get a mutable reference to each head of l1 and l2
var currentL1: ListNode? = l1
var currentL2: ListNode? = l2
// Create a reference to a node we're going to append on
var sumList: ListNode? = ListNode(-1)
// And a reference to its head
func deleteNode(_ node: ListNode?) {
// First we assign next's .value
node?.val = node?.next?.val ?? Int()
// And then next's .next
node?.next = node?.next?.next
}