4

나는 엔티티가 dealdeal이 거래의 객체가 가게에 삽입 된 시간 date라는 속성이 있습니다라고합니다.핵심 데이터로 하루 단위로 그룹화하는 방법은 무엇입니까?

어느 날 여러 deal들 수있다.

그래서 나는 내가 좋아하는 daycountofsomething
가져 싶은 일에 의해 일부 데이터 그룹을 계산합니다 :

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의 수를 계산 때 그것을 어떻게의

+0

는 그렇게 할 수있는 방법이없는 것 같다. 에 따르면 http://stackoverflow.com/questions/9359437 – Puttin

답변

4

샘플은 다음과 같이 될 것이다.

({ 
    count = 1; 
    notes = "glenny and me"; 
}, 
{ 
    count = 6; 
    notes = macair; 
}) 
+0

아,이 질문을 거의 잊을 것입니다. 나는 언젠가 나 혼자서 풀었다. 그러나 아직도 당신의 대답에 감사드립니다! – Puttin

+0

@nhahtdh 편집 해 주셔서 감사합니다. – Puttin

+0

@PuttinWong 어떻게 해결 했습니까? –

관련 문제