코어 데이터에 저장된 브랜드 목록이 있습니다. 각 브랜드는 여러 내용과 연관되어 있습니다. 콘텐츠에는 콘텐츠가 다운로드되었는지 여부를 나타내는 데 사용되는 downStatus
이라는 플래그가 있습니다. 다음 방법은여러 값으로 코어 데이터 정렬
-(void)getDownloadedBrands{
AppDelegate *aAppDelegate = (AppDelegate *)[UIApplication sharedApplication].delegate;
NSMutableArray *aBrands = [[NSMutableArray alloc] init];
NSEntityDescription *entity =
[NSEntityDescription entityForName:@"Brand" inManagedObjectContext:aAppDelegate.managedobjectcontext];
NSFetchRequest *request = [[NSFetchRequest alloc] init];
[request setEntity:entity];
NSSortDescriptor *sort=[[NSSortDescriptor alloc]initWithKey:@"brandName" ascending:YES];
//NSSortDescriptor *sort1=[[NSSortDescriptor alloc]initWithKey:@"downStatus" ascending:YES];
[request setSortDescriptors:[NSArray arrayWithObjects:sort, nil]];
aBrands =(NSMutableArray *)[aAppDelegate.managedobjectcontext executeFetchRequest:request error:nil];
[request release];
[sort release];
NSLog(@"%@",aBrands);
brands = [[NSMutableArray alloc]initWithArray:aBrands];
aAppDelegate.dbBrandArr = brands;
[self loadGridView];
}
가 지금은 내용에있는 downStatus
를 사용하여 정렬 할 브랜드로 분류 핵심 데이터의 모든 브랜드를 가져 오는 데 사용됩니다. 따라서 알파벳순으로 다운로드 한 브랜드와 알파벳순으로 다운로드하지 않은 브랜드가됩니다. downStatus
은 다운로드하지 않은 0
에 대해 1
의 값을 2 개 받아들입니다. 도와주세요. 그것을 할 수
안녕하세요, 답장을 보내 주셔서 감사합니다. 이제는이 오류를 알려줍니다. *** 캐치되지 않은 예외로 인해 앱이 종료 중입니다. 'NSInvalidArgumentException', 이유 : 'keypath downStatus가 엔티티에 없습니다'라는 메시지가 표시됩니다. 'downStatus'가 Content에 있기 때문에 브랜드 없음 –
LeXeR
Core Data 객체에 downStatus 속성이 없습니까? 핵심 데이터에서 어떤 종류의 데이터를 가져오고 있습니까? 나는 사전을 추측하고있다. 그렇다면 다른 접근법이 필요할 것이다. – Michael
실제로'Content'는'Brand'와 연관되어 있고 각 내용은'downStatus' 속성이'1' 또는'0'으로되어 있습니다. downStatus가 1 또는 0이고 brandName으로 정렬 된 모든 브랜드를 가져와야합니다. 나는 여기에 어떤 관계를 언급해야 할 수도 있지만 그것을 어떻게 해야할지 모르겠다. – LeXeR