2011-11-10 4 views
0

필자는 프로젝트에서 데이터를 저장하기 위해 coredata를 사용합니다.coredata에서 min-id 객체를 얻는 방법은 무엇입니까?

 
    NSFetchRequest *request = [NSFetchRequest fetchRequestWithEntityName:@"TestItem"]; 
    NSArray *items = [managedObjectContext executeFetchRequest:request error:&error]; 

    NSLog(@"got entities count %d", [items count]); 
    for(TestItem *item in items){ 
     NSLog(@" entity id:%@, name:%@, date:%@", item.id, item.name, item.date); 
    } 

을 다음하지만 어떻게 최소한의 ID를 가지고 하나 개의 객체를 얻기 위해 같은

이 난 상황에서 모든 개체를 얻을 수 있습니까 ??

답변

0

글쎄, 당신은 가져 오기 개체를 정렬 할 수 있고 그것을 1 개체로 제한 할 수 있습니다. 또한 세션 137 (WWDC 비디오 2010)과 같은 속임수를 사용하여 하위 쿼리를 추가 할 수도 있습니다 : SUBQUERY(things, $thing)[email protected] == XXX 특정 작업이 필요한 경우.

관련 문제