Skip to content

Instantly share code, notes, and snippets.

@laevandus
Created September 8, 2023 08:41
Show Gist options
  • Save laevandus/0e5cc6ffe60d2ec0b3a382a1679bd273 to your computer and use it in GitHub Desktop.
Save laevandus/0e5cc6ffe60d2ec0b3a382a1679bd273 to your computer and use it in GitHub Desktop.
struct Contact {
let firstName: String
let lastName: String
let idCode: String
let address: CNPostalAddress
}
extension Contact: CustomStringConvertible {
var description: String {
"\(firstName) \(lastName)"
}
}
print (contact) // prints description
// John Doe
dump(contact) // prints all the properties v John Doe
// - firstName: "John"
// - lastName: "Doe"
// - idCode:
// "id123"
// - address: <CMutablePostalAddress: 0x600000338410: street=, subLocality=, city=Tokyo, subAdministrativeArea=, state=, postalCode=, country=Japan, countryCode=> #0
// - super: CNPostalAddress
// - super: NSObject
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment