zoukankan      html  css  js  c++  java
  • Chapter 23 Core Data

    Chapter 23 Core Data

     

    1.  Core Data is only able to store certain data types in its store, and UIImage is not one of these types. Instead, you declared the UIImage as transformable. With a transformable attribute, Core Data will convert the object into NSData when saving, and convert the NSData back into the original object when loading it from the file system. In order for Core Data to do this, you have to supply it with an NSValueTransformer subclass that handles these conversions. 

     

    2. An NSManagedObject is little more than a data container. If you need your model objects to do something in addition to holding data, you must subclass NSManagedObject. Then, in your model file, you specify that this entity is represented by instances of your subclass, not the standard NSManagedObject.

     

    3. The portal through which you talk to the database is the NSManagedObjectContext. The NSManagedObjectContext uses an NSPersistentStoreCoordinator. You ask the persistent store coordinator to open a SQLite database at a particular filename. The persistent store coordinator uses the model file in the form of an instance of NSManagedObjectModel. The persistent store coordinator needs to know two things:” What are all of my entities and their attributes and relationships?” and “Where am I saving and loading data from?” To answer these questions, you need to create an instance of NSManagedObjectModel to hold the entity information and initialize the persistent store coordinator with this object. Then you will create the instance of NSManagedObjectContext and specify that is use this persistent store coordinator to save and load objects.

     

    4.  To get objects back from the NSManagedObjectContext, you must prepare and execute an NSFetchRequest. After a fetch request is executed, you will get an array of all the objects that match the parameters of that request.

  • 相关阅读:
    jquery之滚楼
    jquery之仿京东菜单
    jquery之鼠标移动[沸腾京东]
    jquery之飘雪
    jquery之手风琴
    jquery 开始与结束方法 loading窗
    JS对象与数组
    Selenium+Python浏览器调用:Firefox
    Python脚本检查网页是否可以打开
    ubuntu安装pycharm教程
  • 原文地址:https://www.cnblogs.com/1oo1/p/4007460.html
Copyright © 2011-2022 走看看