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 encrypt(_ text: String) -> String? { | |
guard | |
let bundle = Bundle(identifier: "com.example.bundle.identifier"), | |
let url = bundle.url(forResource: "certificate", withExtension: "der"), | |
let certData = try? Data(contentsOf: url), | |
let cert = SecCertificateCreateWithData(nil, certData as CFData) else { | |
print("Couldn't find/create pinned certificate") | |
return nil | |
} | |
var trust: SecTrust? |
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 | |
protocol P { | |
var required: String { get } | |
} | |
extension P { | |
var required: String { "Default implementation of `required`" } | |
var nonRequired: String { "Default implementation of `nonRequired`" } | |
} |
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
extension RawRepresentable where RawValue: Decodable { | |
init?(from decoder: Decoder) throws { | |
self.init(rawValue: try decoder.singleValueContainer().decode(RawValue.self)) | |
} | |
} | |
enum Enum: String, Codable { | |
case aValidCase, anotherValidCase, unknown | |
init(from decoder: Decoder) throws { |
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 | |
class C: Codable { | |
var p: String? | |
} | |
class D: C { | |
var q: String? | |
} |