from a SQL result set row • Construct a new instance for later insertion into the table • Static finder methods to wrap commonly used SQL queries and return Active Record objects • Update the database and insert into it the data in the Active Record • Get and set the fields • Implement some pieces of business logic Principles of Enterprise Application Architecture by Martin Fowler
test? You unit test, right? • Explicitly hand the NSManagedObjectModel to a list view • Explicitly hand a NSManagedObject to a detail view • Handle signout by releasing the NSManagedObjectContext
[NSPredicate predicateWithFormat:@"logId = %@”, Id]; NSArray *res = [sleeps filteredArrayUsingPredicate:p]; if (res.count == 0) { // create } else { // find } } The above loop is O(n^2). In real code, I have an NSEnumerator that makes it O(n).
NSManagedObject by default • Pass in a NSFetchRequest for list views • Pass in a child NSManagedObjectContext for edits • Pass in the entire NSManagedObjectContext only if you have to