Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>First, create a Core Data Entity that has: userSearchTerm and userSearchDate. And create a record everytime a search is done.</p> <p>Start the code by declaring the fetch request. And use <code>NSPredicate</code> to filter by date:</p> <pre><code>NSFetchRequest *fetchRequest = [[NSFetchRequest alloc] init]; NSEntityDescription *entity = [NSEntityDescription entityForName:@"UserSearches" inManagedObjectContext:managedObjectContext]; [fetchRequest setEntity:entity]; NSPredicate *nameFilter = [NSPredicate predicateWithFormat:@"(userSearchDate like[cd] %@) AND (userSearchTerm like[cd] %@)",weekName,termToFind]; [fetchRequest setPredicate:nameFilter]; </code></pre> <p><em>The [cd] in the like filter specifies it's not case-sensitive. You may also need to change this filter depending on the date and format you want to use</em></p> <p>Then, set the fetchResultType as <code>NSDictionaryResultType</code>:</p> <pre><code>[fetchRequest setResultType:NSDictionaryResultType]; </code></pre> <p>This will return a dictionary which you can use.</p> <p>To use aggregate functions you need to use <code>NSExpressionDescription</code></p> <p>This is an extensive code and I'm not able to test it correctly for you, but you can read it here. On section <strong>Fetching Specific Values</strong>, it describes how to do the aggregate functions: <a href="http://developer.apple.com/mac/library/documentation/Cocoa/Conceptual/CoreData/Articles/cdFetching.html" rel="nofollow noreferrer">http://developer.apple.com/mac/library/documentation/Cocoa/Conceptual/CoreData/Articles/cdFetching.html</a></p> <p>For a reference of all the available aggregate functions for <code>NSExpression</code> go to function <strong>expressionForFunction:arguments:</strong> where the list is located.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload