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 | |
public extension Equatable where Self: Codable { | |
static func ==(lhs: Self, rhs: Self) -> Bool { | |
lhs.jsonData == rhs.jsonData | |
} | |
} | |
public extension Person: Equatable { } |
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 | |
public protocol Imitable: Codable { | |
var copy: Self? { get } | |
} | |
extension Imitable { | |
public var copy: Self? { | |
guard let data = try? JSONEncoder().encode(self) else { return nil } | |
return try? JSONDecoder().decode(Self.self, from: data) |
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 SwiftUI | |
struct SampleView: View { | |
var texts = ["SwiftUI", "A new declarative UI framework", "Let us try to understand how SwiftUI renders its views"] | |
@State var selected = 0 | |
@State var textFieldValue = "" | |
@State var isSwitchOn = false | |
NewerOlder