Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>So another few hours digging into internet search results and trying things and I <em>sort</em> of have this working.</p> <pre><code>NSDate * userDate = [NSDate dateWithNaturalLanguageString: inWhenString]; NSDateComponents * userDateComponents = [[NSCalendar currentCalendar] components: NSYearCalendarUnit | NSMonthCalendarUnit | NSDayCalendarUnit fromDate: userDate]; NSDate * dayDate = [[NSCalendar currentCalendar] dateFromComponents: userDateComponents]; dNSLog(@"date %@", dayDate ); NSString * formatStr = [NSDateFormatter dateFormatFromTemplate: @"yyyy-MM-dd" options: 0 locale: nil]; NSDateFormatter * formatter = [[NSDateFormatter alloc] init]; [formatter setDateFormat: formatStr]; NSString * dayStr = [formatter stringFromDate: dayDate]; dayStr = [dayStr stringByAppendingString: @"*"]; dNSLog(@"dayString: %@", dayStr ); NSPredicate *p1 = [NSPredicate predicateWithFormat: @"%K &gt;= CAST(%f, \"NSDate\")", @"kMDItemAccessedDates", [dayDate timeIntervalSinceReferenceDate] ]; NSPredicate *p2 = [NSPredicate predicateWithFormat: @"%K &lt;= CAST(%f, \"NSDate\")", @"kMDItemAccessedDates", [dayDate timeIntervalSinceReferenceDate] + 86400.0f ]; predicate = [NSCompoundPredicate andPredicateWithSubpredicates: @[p1, p2]]; </code></pre> <p>There may be other issues with this whole approach (based on how the app updates this array of dates) that may require me to do something else entirely, but this seems to answer the original question of how to fetch only items that were accessed on a particular day.</p> <p>The key was the <code>CAST(%f, \"NSDate\")</code> I believe.</p> <p>There might still be a better way, but I thought I'd put this up here in case someone else is digging around for any clues.</p>
    singulars
    1. This table or related slice is empty.
    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.
 

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