Using Objective-C blocks to log Core Data entities

Posted by on Nov 17, 2010 in code | No Comments

Usually when I want to log the Core Data entities returned by a query in a particular context, I just passed the object to a log statement, like so: 
NSLog(@"Query returned %@", theCoreDataObject); This works OK when you just have one object to log, but if you want to log the whole array of entities, […]

Log userInfo, not localizedDescription, for CoreData errors

Posted by on Oct 12, 2010 in code | No Comments

Most of the Core Data code samples out there log [error localizedDescription] on errors. However, that will return a message that isn’t particularly useful, like: The operation couldn’t be completed. (Cocoa error 1570.) Instead, if you log [error userInfo], you’ll get a much more actionable message, like: { NSLocalizedDescription = “The operation couldnU2019t be completed. […]