This gist is part of a blog post. Check it out at:
http://jasonrudolph.com/blog/2011/08/09/programming-achievements-how-to-level-up-as-a-developer
This gist is part of a blog post. Check it out at:
http://jasonrudolph.com/blog/2011/08/09/programming-achievements-how-to-level-up-as-a-developer
import UIKit | |
class TouchForwardingView: UIView { | |
var passthroughViews: [UIView] = [] | |
override func hitTest(_ point: CGPoint, with event: UIEvent?) -> UIView? { | |
guard let hitView = super.hitTest(point, with: event) else { return nil } | |
guard hitView == self else { return hitView } | |
import Combine | |
import CoreData | |
extension NSManagedObjectContext { | |
func changesPublisher<Object: NSManagedObject>(for fetchRequest: NSFetchRequest<Object>) | |
-> ManagedObjectChangesPublisher<Object> | |
{ | |
ManagedObjectChangesPublisher(fetchRequest: fetchRequest, context: self) | |
} | |
} |
import SwiftUI | |
import WebKit | |
import Combine | |
class WebViewData: ObservableObject { | |
@Published var loading: Bool = false | |
@Published var scrollPercent: Float = 0 | |
@Published var url: URL? = nil | |
@Published var urlBar: String = "https://nasa.gov" | |
/* | |
Notes: | |
The font modifier requires the following gist: | |
https://gist.github.com/shaps80/2d21b2ab92ea4fddd7b545d77a47024b | |
*/ |
// | |
// BottomSheetView.swift | |
// | |
// Created by Majid Jabrayilov | |
// Copyright © 2019 Majid Jabrayilov. All rights reserved. | |
// | |
import SwiftUI | |
fileprivate enum Constants { | |
static let radius: CGFloat = 16 |
import Combine | |
import ComposableArchitecture | |
import UserNotifications | |
public struct UserNotificationClient { | |
public var add: (UNNotificationRequest) -> Effect<Void, Error> | |
public var delegate: Effect<DelegateEvent, Never> | |
public var getNotificationSettings: Effect<Notification.Settings, Never> | |
public var removeDeliveredNotificationsWithIdentifiers: ([String]) -> Effect<Never, Never> | |
public var removePendingNotificationRequestsWithIdentifiers: ([String]) -> Effect<Never, Never> |
import SwiftUI | |
fileprivate extension DateFormatter { | |
static var month: DateFormatter { | |
let formatter = DateFormatter() | |
formatter.dateFormat = "MMMM" | |
return formatter | |
} | |
static var monthAndYear: DateFormatter { |
struct Foo: Codable { | |
var name: String | |
@Ignore var foo: Int? | |
} | |
let model = Foo(name: "Ian", foo: 42) | |
let data = try! JSONEncoder().encode(model) | |
print(String(data: data, encoding: .utf8)!) // {"name":"Ian"} | |