Note that there are some explanatory texts on larger screens.

plurals
  1. POCore Data NSDate Comparison
    primarykey
    data
    text
    <p>I am storing a date attribute in Core Data using the datePicker on the iPhone. I want to then compare the date that matches a certain date using == but I can't get it to work. The greater than and less than seem to working fine though. </p> <p>At first I was storing the date directly from the datePicker which also included the time information. So I used the NSCalendar to strip of the time and just store the date. </p> <p>Similarly I take the rhs of the predicate and run it through NSCalendar to extract just the date and do the comparison and I still can't get the == to work.</p> <p>Tried doing a NSLog of the date being stored in CoreData and the date being compared and they look exactly the same 2010-06-19 00:00:00 -7:00 </p> <p>Any pointers will be appreciated.</p> <p>EDIT: I am trying to do the comparison in CoreData using the NSEqualToPredicateOperatorType passed into the</p> <pre><code>+ (NSPredicate *)predicateWithLeftExpression:(NSExpression *)lhs rightExpression:(NSExpression *)rhs modifier:(NSComparisonPredicateModifier)modifier type:(NSPredicateOperatorType)type options:(NSUInteger)options </code></pre> <p>with the lhs being the keypath to entity.dateAttribute and rhs being [NSExpression expressionForConstantValue:myDate];</p> <p>PS: I had the above code and then realized that myDate consisted of a time component so I modified the above code to extract only the day, month and year and use it to send it to NSExpression.</p> <p>Similarly while saving the date, I made sure that I am extracting only the date, month and year and passing it to CoreDate effectively making the time 00:00:00 (I hope!)</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.
    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