1
我正在使用核心數據檢索某些數據。我怎樣才能把這個SQL語句翻譯成核心數據?按核心數據劃分的多個組
SELECT bus, direction from BUSES where latitude > 58.00 and longitude < 34.00 group by bus, direction
換句話說,我喜歡按BUS和DIRECTION分組,但有一個WHERE CLAUSE。
我已經使用這個代碼的嘗試:
request.propertiesToFetch = [NSArray arrayWithObjects:@"bus", @"direction", nil];
request.returnsDistinctResults = YES;
request.resultType = NSDictionaryResultType;
的事情是,如果我只檢索總線和方向,我不能設置一個NSPredicate隨緯度和經度這樣的:
NSPredicate *predicate = [NSPredicate predicateWithFormat:@"(lat > 58) AND (lat < 34)"];
[fetchRequest setPredicate:predicate];
我猜Core Data只是檢索總線和方向,這就是爲什麼NSPredicate不起作用。
和什麼如果我想通過使用兩個值獲取??? – Saad