I am fetching data from iCloud and would like to compare it if it's more recent than the data on the device. However, my if statement evaluates to true even if the iCloud data is older.
Here is my code:
if ([fetchedRemindersRecord objectForKey:@"reminders"] && ([fetchedRemindersRecord.modificationDate compare:userDefaultsModificationDate] == NSOrderedDescending)){
[self createReminders:[NSKeyedUnarchiver unarchiveObjectWithData:[fetchedRemindersRecord objectForKey:@"reminders"]]];
NSLog(@"user defaults date: %@",userDefaultsModificationDate);
NSLog(@"icloud fetch date : %@",fetchedRemindersRecord.modificationDate);
}
Console:
user defaults date: 2016-08-28 21:45:24 +0000
icloud fetch date : 2016-08-28 21:34:49 +0000
As you can see clearly, iCloud data is older, however the if statement still evaluates to true. I even checked to make sure that both dates are not nil
before comparing. Changing it to NSOrderedAscending
doesn't work either..
I have been struggling with this for an hour, can't seem to figure out what's going on.. probably some obvious thing which I am overlooking.
Thanks in advance!
Aucun commentaire:
Enregistrer un commentaire