Prine
Prine

Reputation: 12528

CoreData in XCode create a NSFetchRequest returning all entities from today

Is there any solution to create a NSFetchRequest in the XCode view which is returning all entities from "today"? In the view you can only specify a date but not dynamically define today.

Create a NSFetchRequest in XCode

I know that I can also create a NSFetchRequest directly in the code and there I can specify the date dynamically but I was just wondering if this is also possible directly in XCode without writing any code.

Upvotes: 0

Views: 119

Answers (1)

Mundi
Mundi

Reputation: 80265

Yes it is possible. You can specify a variable $TODAY and use it in code like so:

NSFetchRequest *fetchRequest =   [self.managedObjectModel
  fetchRequestFromTemplateWithName:@"ScanFetch" 
  substitutionVariables:@{@"TODAY":[NSDate date]}];

Upvotes: 2

Related Questions