This file contains 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 CoreData | |
class CoreDataStack { | |
let modelName = "Data Model Name" | |
private lazy var applicationDocumentsDirectory: NSURL = { | |
let urls = NSFileManager.defaultManager().URLsForDirectory(.DocumentDirectory, inDomains: .UserDomainMask) | |
This file contains 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 | |
protocol PostGateway { | |
func getPosts(completion: (String) -> Void) | |
} | |
protocol getPosts { | |
func addPost(postID: String) | |
func removePost(postID: String) | |
func comment() |
This file contains 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 | |
// If you enjoyed this talk (video link will be up soon), then you might also enjoy our book Advanced Swift: http://www.objc.io/books/advanced-swift | |
struct Person { | |
let name: String | |
let city: String | |
} | |
let people = [ |
This file contains 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
# Given a String | |
example_string = "Hello Welcome to New York City" | |
def find_capitals(words): | |
capitals = list() | |
for letter in list(words): | |
# Determine the letters that are capital case | |
if letter.isupper(): | |
# put them into an array |
This file contains 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 fetchForecast(for location: CLLocation) -> AnyPublisher<API, Error> { | |
// before | |
let started = Date() | |
var components = URLComponents() | |
components.path = "/data/2.5/onecall" | |
components.queryItems = [ | |
"lat": String(location.coordinate.latitude), | |
"lon": String(location.coordinate.longitude), | |
"units": "imperial", | |
"appid": "", |
This file contains 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
// 1 | |
.rotationEffect(.degrees(degrees)) |
This file contains 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
// swiftlint:disable all | |
// Generated using SwiftGen — https://github.com/SwiftGen/SwiftGen | |
{% if catalogs %} | |
{% set enumName %}{{param.enumName|default:"Asset"}}{% endset %} | |
{% set colorType %}{{param.colorTypeName|default:"ColorAsset"}}{% endset %} | |
{% set imageType %}{{param.imageTypeName|default:"ImageAsset"}}{% endset %} | |
{% set forceNamespaces %}{{param.forceProvidesNamespaces|default:"false"}}{% endset %} | |
{% set accessModifier %}{% if param.publicAccess %}public{% else %}internal{% endif %}{% endset %} | |
import SwiftUI |
This file contains 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
struct ContentView: View { | |
let colors: [Color] = [ | |
.red, .green, .blue, .gray | |
] | |
var body: some View { | |
GeometryReader { proxy in | |
TabView { | |
ForEach(colors, id: \.self) { color in | |
color // Your cell content |
This file contains 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
struct ContentView: View { | |
let colors: [Color] = [ | |
.red, .green, .blue, .gray | |
] | |
var body: some View { | |
GeometryReader { proxy in | |
TabView { | |
ForEach(colors, id: \.self) { color in | |
color // Your cell content |
This file contains 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 search(needle: String, haystack: String) -> Bool { | |
guard needle.count <= haystack.count else { | |
return false | |
} | |
if needle == haystack { | |
return true | |
} | |
var needleIdx = needle.startIndex |
OlderNewer