배열 self.contacts 의 first_name 에 따라 기본 배열을 정렬하고 싶습니다.
배열을 정렬하는 데 사용되는 코드
-(void)Sort
{
NSSortDescriptor *sdName = [[NSSortDescriptor alloc] initWithKey:@"first_name" ascending:YES];
self.contacts = [NSMutableArray arrayWithArray:[self.contacts sortedArrayUsingDescriptors:[NSArray arrayWithObjects:sdName, nil]]];
}
MyData
self.contacts = (
{
contact = {
"first_name" = "Test R";
};
"last_met" = (
{
"last_met_date" = "2014-10-09";
}
);
},
{
contact = {
"first_name" = "Test K";
};
"last_met" = (
{
"last_met_date" = "2014-10-09";
}
);
}
)
이 정렬 설명 자로 시도하십시오.
descriptor = [[NSSortDescriptor alloc] initWithKey:@"contact.first_name"
ascending:YES];
매개 변수는 key
사실입니다 키 경로 및 NSDictionary
KV를 준수합니다. 다음과 같이 작성할 수 있습니다 [contacts[0] valueForKeyPath:@"contact.first_name"]
..
이 기사는 인터넷에서 수집됩니다. 재 인쇄 할 때 출처를 알려주십시오.
침해가 발생한 경우 연락 주시기 바랍니다[email protected] 삭제
몇 마디 만하겠습니다