3
안녕하세요. 내 앱은 국가별로 그룹화 된 도시 (거리) 목록을 보여줍니다. 나는 새로운 길을 저장할 때 , 그것은 다음과 같습니다CoreData 속성을 고유하게 필터링하고 UITableView에 표시하십시오.
Country -> USA
City-> New York
street-> timeSqaure
것은 내가이만큼의 거리 저장할 때 :
Country -> USA
City-> New York
street-> 233 street 330 west
내의 TableView은 도시 Screenshot
중복을 나는를 필터링 할 수있는 방법 독특한 도시로 중복 된 도시. 이 같은
가져 오기 내 외모는 :
-(void) performFetch
{
NSFetchRequest *request = [[NSFetchRequest alloc] init];
NSManagedObjectContext *context = [app managedObjectContext];
NSEntityDescription *entity = [NSEntityDescription entityForName:@"Country" inManagedObjectContext:context];
[request setEntity:entity];
NSSortDescriptor *sort1 = [[NSSortDescriptor alloc] initWithKey:@"country" ascending:YES];
NSArray *sortArray = [NSArray arrayWithObjects:sort1, nil];
[request setSortDescriptors:sortArray];
NSError *error;
self.fetchedResultsController =[[NSFetchedResultsController alloc] initWithFetchRequest:request managedObjectContext:context sectionNameKeyPath:@"country" cacheName:nil];
if (![self.fetchedResultsController performFetch:&error]) {
NSLog(@"failure: %@", [error localizedDescription]);
}
}
투표 후보자 아래에있는 '틱'을 클릭하여이 대답을 수락 한 것으로 표시해야합니다. –