The historical CoreData data persistence framework of the CoreData database framework is part of the Cocoa API. It first appeared in the iOS3.0 system and allows data to be organized according to the entity-Attribute-value model, and persistent data in XML, binary, or SQLite data file format.
Common class entity management class of 2-core data database framework: NSManagedObject Entity description class: NSEntityDescription Data Manager class: NSManagedObjectContext data connector class: NSPersistentStoreCoordinator data model type: NSManagedObjectModel
Relationship between three CoreData classes
4. Use CZ compute? Http://www.bkjia.com/kf/ware/vc/ "target =" _ blank "class =" keylink "> vcmVEYXRhyv2 + 3b/iv/release + us2z1r7Du6 + release/release + release/b7dPC9oMz4KPHA + PGJyPgo8L3A + primary/standby + 3 TwvaDM + primary/standby + PGJyPgo8L3A + primary/zyc/primary/e6zcq508PK/b7dLCC /keys + 3b/iLCC4tNbGyv2 + 3bW9xNq05iwgsqKyu9Owz + zUrcq8yv2 + 3 Swgs/23x8i3yM + keys + 3 crHvt/keys + keys = "brush: java; "> // Override to support editing the table view. -(void) tableView :( UITableView *) tableView commitEditingStyle :( UITableViewCellEditingStyle) editingStyle forRowAtIndexPath :( NSIndexPath *) indexPath {if (editingStyle = UITableViewCellEditingStyleDelete) {// Delete the row from the data source // Delete the element [self. context deleteObject: [self. itemInfoArray objectAtIndex: indexPath. row]; // Delete the element [self. itemInfoArray removeObjectAtIndex: indexPath. row]; // Delete Cell [tableView deleteRowsAtIndexPaths: @ [indexPath] withRowAnimation: UITableViewRowAnimationFade]; // Save the change [self. context save: nil];} else if (editingStyle = UITableViewCellEditingStyleInsert) {// Create a new instance of the appropriate class, insert it into the array, and add a new row to the table view }}
NSManagedObjectMode, an object model, multiple NSManagedObject, managed object, and data model returned by CoreData. The managed object is the NSEntityDescription generated based on the Entity description, object Description class: Creates the managed object Entity and Object Class Based on the object. The question is the description of the file data. the managed object indicates the object. The object contains the name, attribute (field), and link. The object name is usually the same as the name of the managed object.
Data Query NSFetchRequest. query requests can be sorted or predicate.
// Retrieve data from CoreData NSFetchRequest * fetchRequest = [[NSFetchRequest alloc] initWithEntityName: @ "AddCoreData"];
NSSortDescriptor, sorting operation
// The sorting rule ascending is YES. The ascending order is NO. the descending order NSSortDescriptor * sortDescriptor = [NSSortDescriptor OPERATOR: @ "currentDate" ascending: YES]; [fetchRequest setSortDescriptors: @ [sortdescrip // set the sorting rule // who is required to follow the sorting rule [self. context executeFetchRequest: fetchRequest error: nil];
NSManagedObjectContext queries Data Based on NSFetchRequest and returns data in an array. The array contains the managed object.
// Store the obtained data in the array [self. itemInfoArray setArray: [self. context executeFetchRequest: fetchRequest error: nil];
5. Advanced approaches to using the CoreData database framework
Model Version Upgrade and data migration CoreData supports the management of ManagedObjectModel upgrade or modification brought about by App development and evolution. changes to the model will result in incompatibility (or inaccessibility) of the storage created in previous versions. if you want to change your model, you must change the data in the existing storage, that is, the data storage format (store format)-This is called migration (migration)
Summary The core of CoreData data framework implementation is that all interactions between the persistent storage stack and CoreData database framework are completed through NSManagedObjectContext. Data in NSManagedObjectContext is cached in the memory, to achieve persistence, update and save.