How to get only object identifiers, but also include row data in CoreData?

In Apple's Apple CoreData Docs running in the background , I came across this tip:

For example, you can configure a query to retrieve only object identifiers , and also include row information (and update row cache) . This can be useful if you are just going to go through those object identifiers from a background thread to another thread.

I was wondering how you can implement this query on a sample? In particular, how to update the line cache.

I think that here is how to get only identifiers:

NSFetchRequest* request = [NSFetchRequest fetchRequestWithEntityName:@"MyItem"]; // iOS 5 method
request.returnsObjectsAsFaults = YES; 

How do I do the rest?

+3
source share
2

includePropertyValues ​​ YES, returnObjectsAsFaults YES.

, ...

fetchRequest.resultType = NSManagedObjectIDResultType;

, , . .

, BY DEFAULT (resultType == NSManagedObjectResultType), includePropertyValues ​​ returnsObjectsAsFaults YES, ( ), , " ", - ... .

, , - objectID.

, , , , , , . , , - , , ?

... , , . - , returnObjectsAsFaults ​​- . , includePropertyValues ​​ - .

objectID, , , managedObject.objectID.

, , , , , .

NSFetchRequest , .

resultType NSManagedObjectResultType. , , , NSManagedObjectResultType. , , , NSManagedObjects ( ObjectID).

returnsObjectsAsFaults YES. , , , . , , , . NSManagedObject . . , , .

includesPropertyValues ​​ YES. , , , . , .

NSManagedObject, , :

  • , .

, . , ( ).

, , resultType NSManagedObjectIDResultType.

NSFetchRequest...

includesPropertyValues ​​

includePropertyValues ​​ NO, . , , , , , .

(includePropertyValues ​​ ), , (. returnObjectsAsFaults). , . , Core Data - .

includePropertyValues ​​, Core Data - ​​ . - , . , , Core Data () , , .

...

returnsObjectsAsFaults

- YES. , (. resultType) - NSManagedObjectIDResultType, . returnObjectsAsFaults NO , .

returnObjectsAsFaults - ; , . , , . , Core Data . , . (, ), returnObjectsAsFaults NO, .

+13

NSFetchRequest

resultType: NSManagedObjectResultType

returnsObjectsAsFaults: YES

includesPropertyValues: YES

( ) objectID, ( fault)

includesPropertyValues ​​

: , ( CoreData), , , CoreData

: , , CoreData SQLite

returnsObjectsAsFaults

: PropertyValues ​​( )

NO: wilh

: 2 :

Faulting

,

+4

All Articles