class Dog: Object {
dynamic var id = ""
dynamic var name = ""
dynamic var tempVariable = ""
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
// | |
// StringDimensionProvider.swift | |
// | |
// Created by steve on 2019-07-11. | |
// Copyright © 2019 Steven Thompson. All rights reserved. | |
// | |
// | |
// StringHeightProvider.swift | |
// |
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
enum CommunityProfileSection { | |
case FacilityName(String?) | |
case ContactInfo(ProfileContactViewModel) | |
case LocationInfo([ExpandableProfileModel]) | |
} | |
extension CommunityProfileSection { | |
var facilityName: String? { | |
if case let .FacilityName(name) = self { |
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 | |
extension UICollectionReusableView { | |
/** | |
Used for creating dynamic height cells | |
- Call from overridden UICollectionReusableView (Cell) method `preferredLayoutAttributesFitting(_:)` which the system calls | |
- Setup the cell width in `sizeForItem` as usual & pass a temp height | |
- Setup Autolayout on cells to ensure a height can be computed | |
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 | |
struct ViewModel1 { | |
let title = "Hello" | |
} | |
struct ViewModel2 { | |
let message = "some message" | |
} |
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
protocol Equating { | |
func isEqualTo(_ other: Equating)-> Bool | |
} | |
extension Equating where Self: Equatable { | |
func isEqualTo(_ other: Equating) -> Bool { | |
guard let other = other as? Self else { return false } | |
return other == self | |
} | |
} |
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
public struct AnyEquatable: Equatable { | |
private let value: Any | |
private let equals: Any -> Bool | |
public init<E: Equatable>(_ value: E) { | |
self.value = value | |
self.equals = { ($0 as? E == value) ?? false } | |
} | |
} |
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 testNotifications() { | |
// map all authorizationStatus with expected Result | |
let authorizationStatusMap: [UNAuthorizationStatus: Int] = [.authorized: 1, .denied: 0, .notDetermined: 0, .provisional: 1] | |
UNNotificationSettings.swizzleAuthorizationStatus() | |
authorizationStatusMap.forEach { (key: UNAuthorizationStatus, value: Int) in | |
UNNotificationSettings.fakeAuthorizationStatus = key | |
let mockCenter = UserNotificationCenterMock() | |
let mockCoder = MockNSCoder() |
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 | |
final class Sample: NSObject { | |
@objc dynamic var name: String = "" | |
} | |
class MyObj: NSObject { | |
@objc dynamic var test: String = "" | |
} | |
extension NSObjectProtocol where Self: NSObject { |
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 | |
func g(_ b: String) -> String { | |
b | |
} | |
func f(_ s: String?) -> String? { | |
guard let unwrappedS = s else { | |
return nil | |
} |
NewerOlder