Core Data

Tutorials

 * http://www.raywenderlich.com/999/core-data-tutorial-how-to-use-nsfetchedresultscontroller
 * http://developer.apple.com/library/mac/#documentation/cocoa/reference/CoreDataFramework/Classes/NSManagedObjectContext_Class/NSManagedObjectContext.html
 * http://developer.apple.com/library/ios/#documentation/CoreData/Reference/NSFetchedResultsController_Class/Reference/Reference.html
 * http://cocoawithlove.com/2009/01/serving-nsmanagedobjectcontext-over.html
 * http://www.cimgf.com/2011/01/07/passing-around-a-nsmanagedobjectcontext-on-the-iphone/
 * http://developer.apple.com/library/mac/#documentation/Cocoa/Conceptual/CoreData/Articles/cdCreateMOs.html
 * http://cocoawithlove.com/2008/06/speed-test-nsmanagedobject-objc-20.html
 * http://www.cimgf.com/2010/02/18/creating-a-nsmanagedobject-that-is-cross-platform/
 * http://stackoverflow.com/questions/2745999/how-to-set-custom-attribute-of-nsmanagedobject-which-is-calculated-from-other-att

NSFetchedResultsControllerDelegate
- (NSFetchedResultsController *)fetchedResultsController { if (_fetchedResultsController != nil) { return _fetchedResultsController; }   NSFetchRequest *fetchRequest = NSFetchRequest alloc] init];    NSEntityDescription *entity = [NSEntityDescription         entityForName:@"FailedBankInfo" inManagedObjectContext:_context];    [fetchRequest setEntity:entity];    NSSortDescriptor *sort = [[NSSortDescriptor alloc]         initWithKey:@"details.closeDate" ascending:NO];    [fetchRequest setSortDescriptors:[NSArray arrayWithObject:sort;    [fetchRequest setFetchBatchSize:20];    NSFetchedResultsController *theFetchedResultsController =         [[NSFetchedResultsController alloc] initWithFetchRequest:fetchRequest             managedObjectContext:_context sectionNameKeyPath:nil             cacheName:@"Root"];    self.fetchedResultsController = theFetchedResultsController;    _fetchedResultsController.delegate = self;    [sort release];    [fetchRequest release];    [theFetchedResultsController release];    return _fetchedResultsController;    }
 * http://iphonedevelopment.blogspot.com/search?q=nsfetchedresultscontroller
 * http://www.raywenderlich.com/999/core-data-tutorial-how-to-use-nsfetchedresultscontroller
 * http://developer.apple.com/library/ios/#documentation/CoreData/Reference/NSFetchedResultsController_Class/Reference/Reference.html

Introduction

 * http://cocoadevcentral.com/articles/000086.php
 * http://www.mactech.com/articles/mactech/Vol.21/21.11/CoreDataIII/
 * http://www.mactech.com/articles/mactech/Vol.22/22.02/CoreData4/

Errors
NSManagedObjectValidationError                  = 1550, NSValidationMultipleErrorsError                 = 1560, NSValidationMissingMandatoryPropertyError       = 1570, NSValidationRelationshipLacksMinimumCountError  = 1580, NSValidationRelationshipExceedsMaximumCountError = 1590, NSValidationRelationshipDeniedDeleteError       = 1600, NSValidationNumberTooLargeError                 = 1610, NSValidationNumberTooSmallError                 = 1620, NSValidationDateTooLateError                    = 1630, NSValidationDateTooSoonError                    = 1640, NSValidationInvalidDateError                    = 1650, NSValidationStringTooLongError                  = 1660, NSValidationStringTooShortError                 = 1670, NSValidationStringPatternMatchingError          = 1680,
 * http://stackoverflow.com/questions/1283960/iphone-core-data-unresolved-error-while-saving
 * http://developer.apple.com/mac/library/documentation/Cocoa/Reference/CoreDataFramework/Miscellaneous/CoreData_Constants/Reference/reference.html

Versioning

 * http://www.timisted.net/blog/archive/core-data-migration/

Predicates

 * http://developer.apple.com/mac/library/documentation/Cocoa/Conceptual/Predicates/Articles/pCreating.html

Transient
NSSortDescriptor * nameInitialSortOrder = [[[NSSortDescriptor alloc]   initWithKey:@"committeeNameInitial" ascending:YES] autorelease];
 * http://www.2pi.dk/tech/cocoa/transient_properties.html
 * http://stackoverflow.com/questions/1112521/nsfetchedresultscontroller-with-sections-created-by-first-letter-of-a-string

[fetchRequest setSortDescriptors:[NSArray arrayWithObject:nameInitialSortOrder]];

NSFetchedResultsController *aFetchedResultsController = [[NSFetchedResultsController alloc]    initWithFetchRequest:fetchRequest     managedObjectContext:managedObjectContext     sectionNameKeyPath:@"committeeNameInitial" cacheName:@"Root"];
 * sectionNameKeyPath is sort of like a grouping expression. The sort descriptor really determines the sorting and the sectionNameKeyPath just display's itself every time it changes. The sort descriptor ordering must not violate the sectionNameHeader rules (namely, that a section cannot reappear).

Non-Standard Persistent Attributes

 * http://developer.apple.com/mac/library/documentation/Cocoa/Conceptual/CoreData/Articles/cdNSAttributes.html

Predicates

 * subquery, any, between
 * Date based Predicate Example

Misc

 * http://blog.sallarp.com/iphone-core-data-uitableview-drill-down/
 * http://stackoverflow.com/questions/2197496/fixing-predicated-nsfetchedresultscontroller-nsfetchrequest-performance-with-sqli

Key Value Coding

 * http://www.cimgf.com/2008/04/15/cocoa-tutorial-get-the-most-out-of-key-value-coding-and-observing/

Preloading Data
// import default information from DefaultData.xml NSFileHandle *fileHandle = [NSFileHandle fileHandleForReadingAtPath:[applicationSupportFolder stringByAppendingPathComponent:@"DefaultData.xml"]]; if (fileHandle == nil) { NSPersistentStoreCoordinator *defaultDataStoreCoordinator; NSString *defaultPath = NSBundle mainBundle] pathForResource:@"DefaultData" ofType:@"xml"];       if (defaultPath) {            NSURL *defaultURL = [NSURL fileURLWithPath:defaultPath];            defaultDataStoreCoordinator = [[NSPersistentStoreCoordinator alloc] initWithManagedObjectModel:[self managedObjectModel;            if(![defaultDataStoreCoordinator addPersistentStoreWithType:NSXMLStoreType configuration:nil URL:defaultURL options:nil error:&error]) {                NSApplication sharedApplication] presentError:error];            }            else {                if (![defaultDataStoreCoordinator migratePersistentStore:[defaultDataStoreCoordinator persistentStoreForURL:defaultURL]                                                                   toURL:url options:nil withType:NSXMLStoreType error:&error]) {                    [[NSApplication sharedApplication] presentError:error];                }            }        }        else {            // create a store and file from scratch            persistentStoreCoordinator = [[NSPersistentStoreCoordinator alloc] initWithManagedObjectModel: [self managedObjectModel;            if (![persistentStoreCoordinator addPersistentStoreWithType:NSXMLStoreType configuration:nil URL:url options:nil error:&error]){                NSApplication sharedApplication] presentError:error];            }        }    }    // load data from stored user support folder    else {        persistentStoreCoordinator = [[NSPersistentStoreCoordinator alloc] initWithManagedObjectModel: [self managedObjectModel;        if (![persistentStoreCoordinator addPersistentStoreWithType:NSXMLStoreType configuration:nil URL:url options:nil error:&error]){            [[NSApplication sharedApplication] presentError:error];        }        }
 * http://forums.pragprog.com/forums/90/topics/2436


 * http://ablogontech.wordpress.com/2009/07/13/using-a-pre-populated-sqlite-database-with-core-data-on-iphone-os-3-0/


 * 1) Use Spotlight to search for the SQLite database created by the app in the iPhone Simulator. This is /Users//Library/Application Support/iPhone Simulator/User/Application//Documents/
 * 2) Copy that database to a working folder.
 * 3) Populate that database.
 * 4) Add the populated database to the project.

NSPersistenceDocument

 * http://developer.apple.com/library/mac/#documentation/Cocoa/Conceptual/NSPersistentDocumentTutorial/00_Introduction/introduction.html