我已使用Google搜索,但無法找到解決方案 - 尋找一些幫助。需要從每個名稱的倍數中獲得一個名稱列表(每個名稱只有一個實例)
我有一個包括他們之間的不同位置和距離的數據庫:
beg_location end_location miles
pointA pointB 2
pointA pointC 3
pointB pointA 2
pointB pointC 1
pointC pointA 3
pointC pointB 1
我使用MagicalRecord與CoreData接口 - 我只需要弄清楚如何最好地創建一個包含每個名稱的數組(即「點A,pointB,pointC」)
這裏是我的代碼:
LocationMiles location;
//Create ResultsController
NSFetchedResultsController *fetchedLocationsController = [LocationMiles MR_fetchAllSortedBy:@"beg_location" ascending:YES withPredicate:nil groupBy:@"end_school" delegate:nil];
//turn controller into array
NSArray *fetchedLocations = [fetchedLocationsController fetchedObjects];
//go through array
for (location in fetchedLocations){
NSLog(@"Here is a location: %@", location.beg_location);
}
目前,它給我的結果 - 但他們結果是相似的: 這裏是一個位置:點A 這裏是一個位置:點A 這裏是一個位置:pointB 下面是一個位置:pointB
我只是想獲得該陣列讀取,點A,pointB,pointC所以我應該只有3個位置(我將在稍後將這些位置放入UIPickverview中)。
我敢肯定,在我的邏輯中的東西是錯誤的 - 我只是無法弄清楚什麼。
的問題是,每個點多次出現在數組中。所以如果我刪除了日誌文本並且打印了數組,它會讀取:pointA,pointA,pointB,pointB,pointC,pointC - 這就是我不想要的。 – Hanny