Skip to content

Instantly share code, notes, and snippets.

@stormychel
Created November 20, 2022 21:21
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save stormychel/e6683e6b6c35e88cea6534c755be65d1 to your computer and use it in GitHub Desktop.
Save stormychel/e6683e6b6c35e88cea6534c755be65d1 to your computer and use it in GitHub Desktop.
CoreData: NSManagedObject extension that prints all data to console. Usage: nsManagedObjectName.printContent()
extension NSManagedObject {
/// Print content of object to console.
func printContent() {
print("\nNSManagedObjectID: \(self.objectID) - key/value dump:")
for key in self.entity.attributesByName.keys {
print("\(key): \(self.value(forKey: key) ?? "nil")")
}
print("\n")
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment