0
我有一個entity
其中包含NSDate (format yyyy-MM-dd)
的對象現在我想要做一個fetch request
只有今天有NSDate
的對象。所以我正在做以下事情。帶NSdate謂詞的NSFetchrequest
NSDate *now = [NSDate new];
RKManagedObjectStore *store = [[DominoDataModel sharedDataModel] objectStore];
NSManagedObjectContext *context = store.mainQueueManagedObjectContext;
NSFetchRequest *fetchRequest = [NSFetchRequest fetchRequestWithEntityName:@"Event"];
NSPredicate *predicate = [NSPredicate predicateWithFormat:
@"eve_date = %@",now];
fetchRequest.predicate = predicate;
NSSortDescriptor *descriptor = [NSSortDescriptor sortDescriptorWithKey:@"eve_date" ascending:YES];
fetchRequest.sortDescriptors = @[descriptor];
NSArray *matches = [context executeFetchRequest:fetchRequest error:nil];
arrConcerten = [matches mutableCopy];
NSLog(@"matches %@",matches);
我的NSLog
總是返回無匹配。
有人可以幫助我嗎?
編輯
我的實體包含NSDates這樣的:
2013/08/29
2013/08/30
2013/09/02
2013/09/15
2013/09/28
我以爲我只是這些NSDates今天的日期比較?但是這可能不起作用,因爲我的實體中的NSDates沒有時間戳?
有沒有這樣的事,作爲一個'NSDate'用「格式」。 「eve_date」屬性中的值究竟是什麼? –
是不是這個(幾乎)在你以前的問題相同的問題http://stackoverflow.com/questions/18332769/check-if-an-array-of-custom-objects-contains-an-object-with- A-某些最新的嗎? - 你必須與「一天的開始」和「第二天的開始」進行比較。 –
@CarlVeazey我編輯了我的問題 – Steaphann