Original link: http://www.jianshu.com/p/4411f507dd9f
Description: The coredata described in this article is not created in the Appdelegate, new project is used in the program, that is, the creation of a local database, cache data, after a few hours to update the database
1. Create CoreData: I named Zhzmodel, insert a table: News:
Remark: How to create: Command+n->ios/coredate->datamodel
Describe the data type: True/false with a Boolean, if it is a nsarray or dictionary, with the transformable type, the data type is ID (that is, any type)
2. Generate Nsmanagedobject Subclass: (The Ads property value is self-modified to Nsarray type, generated by ID type)
Remark: (1) Creation method: Command+n->ios/coredate->nsmanagedobject Subclass (2) menu bar editor->create nsmanagedobject SubCl The
3. Create a project that inherits from NSObject: write the following code
Note: If it is not a blog address, please use the address in Baidu Open
Detailed Address: http://blog.csdn.net/rhljiayou/article/details/18037729/
4. In the network parsing data: (self.alldata to customize a mutable array, accept the parsed value)
-Note: This article is from the network reference, for learning only
The above is used in other programs, and now uses a create project directly with CoreData:
Create
Next, create the table, insert the fields, and then generate the files:
Create a table directly (Qhusermodel), insert the fields you want, and then generate the qhusermodel.h/m file
Then create a new inheritance and NSObject Direct management additions and deletions: qhdatabase
Where Qhcommitidymodel is another table I created, no tube, Singleton is a singleton created
Simply take a look at this single example: (Just a. h header file), you can actually write a single-case method in your project:
And then we'll go ahead and see QHDATABASE.M.
Then take a look at the use of the project:
Simple use of coredata in IOS