나는 엔티티가 deal
및 deal
이 거래의 객체가 가게에 삽입 된 시간 date
라는 속성이 있습니다라고합니다.핵심 데이터로 하루 단위로 그룹화하는 방법은 무엇입니까?
어느 날 여러 deal
들 수있다.
그래서 나는 내가 좋아하는 day
및 countofsomething
가져 싶은 일에 의해 일부 데이터 그룹을 계산합니다 :
2013-06-03 3
2013-06-02 4
을 나는 단지 섹션으로 거래를 넣어 때문에 sectionPath
를 사용하지 않습니다.
나는 과 같은 dayOfTheDate
과 같은 다른 속성 (유형 : 문자열)을 사용하여이 작업을 수행 할 수 있음을 알고 있습니다.
이 BTW, 과도 속성은이 상황
당신은 내가 무엇을 찾고 이해할 수에서 작동하지 않는 것?
의견을 보내 주시면 자세히 알려 드리겠습니다.
감사합니다. 나는 같은 노트
NSEntityDescription* entity = [NSEntityDescription entityForName:@"Assets"
inManagedObjectContext:[appDelegate managedObjectContext]];
NSAttributeDescription* statusDesc = [entity.attributesByName objectForKey:@"notes"];
NSExpression *keyPathExpression = [NSExpression expressionForKeyPath: @"assetUrl"]; // Does not really matter
NSExpression *countExpression = [NSExpression expressionForFunction: @"count:"
arguments: [NSArray arrayWithObject:keyPathExpression]];
NSExpressionDescription *expressionDescription = [[NSExpressionDescription alloc] init];
[expressionDescription setName: @"count"];
[expressionDescription setExpression: countExpression];
[expressionDescription setExpressionResultType: NSInteger32AttributeType];
[searchFetchRequest setPropertiesToFetch:[NSArray arrayWithObjects:statusDesc,expressionDescription, nil]];
[searchFetchRequest setPropertiesToGroupBy:[NSArray arrayWithObject:statusDesc]];
NSSortDescriptor *sortDescriptor = [[NSSortDescriptor alloc] initWithKey:@"timestamp" ascending:NO];
[searchFetchRequest setSortDescriptors:@[sortDescriptor]];
[searchFetchRequest setFetchLimit:10];
NSPredicate *query = [NSPredicate predicateWithFormat:@"notes contains[cd] %@",_txtCameraNote.text];
[searchFetchRequest setPredicate:query];
[searchFetchRequest setResultType:NSDictionaryResultType];
NSArray *fetchedObjects = [appContext executeFetchRequest:searchFetchRequest error:nil];
fetchedObjects
의 수를 계산 때 그것을 어떻게의
는 그렇게 할 수있는 방법이없는 것 같다. 에 따르면 http://stackoverflow.com/questions/9359437 – Puttin