Questions tagged [nsfetchrequest]

On macOS 10.4+ and iOS 3.0+, an instance of NSFetchRequest describes the search criteria used to retrieve data from a persistent store. It is a class in the Apple Core Data Framework.

From the NSFetchRequest documentation:

An instance of NSFetchRequest collects the criteria needed to select and optionally to sort a group of managed objects held in a persistent store. (See NSPersistentStore and NSManagedObject.) A fetch request must contain an entity description (an instance of NSEntityDescription) or an entity name that specifies which entity to search. It frequently also contains

  • A predicate (an instance of NSPredicate) that specifies which properties to filter by and the constraints on selection, for example, “last name begins with a ‘J’”. If you don’t specify a predicate, then all instances of the specified entity are selected (subject to other constraints; see executeFetchRequest:error: for full details).

  • An array of sort descriptors (instances of NSSortDescriptor) that specify how the returned objects should be ordered, for example, by last name then by first name.

Questions related to this can also be tagged with .

NSFetchRequest objects can be used with the method executeFetchRequest:error:, defined by NSManagedObjectContext.

Sample syntax:

NSFetchRequest *request = [[NSFetchRequest alloc] init];
NSEntityDescription *entity = [NSEntityDescription entityForName:@"Employee"
                inManagedObjectContext:managedObjectContext];
[request setEntity:entity];
1115 questions
-1
votes
1 answer

how to fetch minimum value of count of to-many sub models in core data

I have two models Practice and PracticeRecord with a to-many relationship between them. Now I want to retrieve an array of Practice objects whose number of associated practiceRecord objects are minimum but greater than zero. I wrote below code but…
-1
votes
1 answer

Core data fetching entity1 and limiting it from a variable

Sorry if i confuse anyone but i am going to try my best to describe my problem. I have an entity named Document and another entity named Customer the Document has an attribute named CustomerID and that gets assigned from the Customer attribute…
Bassem
  • 119
  • 2
  • 7
-3
votes
2 answers

Fetching all data from an Entity and printing only displays the last record

I'm trying to fetch all of the data from a particular Core Data Entity and place each record into a string. However the following code only prints the LAST record that it accesses. What am I doing wrong? NSFetchRequest *fetchRequest =…
-3
votes
1 answer

CoreData - fetch code swift3

below is not working throwing an error , please help how to write a code for fetching data from Users entity. attached screenenter image description here
Srini
  • 5
  • 3
-3
votes
2 answers

Core Data Table Relationship and Fetchrequest

I am developing one iPad application using storyboard and core data.I have no good idea about core data.I have 2 tables names A and B. Table a have 2 fields with names datacode and price.In table B there are two fields with names itemcode and…
user3522400
  • 21
  • 1
  • 5
1 2 3
74
75