Core data involves several major concepts that can be understood by the database: nsmanagedobjectcontext (managed object context): Database nsentitydescription (Entity description): Table nsfetchrequest (request): Command set nspredicate (predicate): some statements in the example given in the query statement can be understood by Common Database Operations nsmanagedobjectcontext * context = [appdelegate managedobjectcontext]; // specify a "Database" nsentitydescription * entitydescription = [[nsentitydescription alloc] entityforname: @ "line" inmanagedobjectcontext: Context]; // specify a "table ", line is the "table name", and context is the "Database" where the "table" is located. nsfetchrequest * request = [[nsfetchrequest alloc] init]; // create an empty "command" [Request setentity: entitydescription]; // specify a target "table" nspredicate * Pred = [nspredicate predicatewithformat: @ "(linenum = % d)", I]; // create a "query" to find the line with linenum = I [Request setpredicate: PRED]; // assign the "command" specific content, that is, implement a "query" nsarray * objects = [context executefetchrequest: Request error: & error]; // execute the "command ", get "result" Objects
Some basic concepts of coredata