2009-06-29 2 views

답변

18
당신은 술어를 사용하여 배열의 "검색"과 같이 할 수

:

NSMutableArray* names = [NSMutableArray arrayWithObjects:@"Andy", @"Bart", @"Bob", nil]; 
NSPredicate* predicate = [NSPredicate predicateWithFormat:@"SELF beginswith[c] 'b'"]; 
NSArray* namesStartingWithB = [names filteredArrayUsingPredicate: predicate]; 
// namesStartingWithB now contains @"Bart" & @"Bob" 

당신은 더의 NSArrayNSPredicate 문서를 봐야한다 정보. XML 구문 분석과 관련된 정보 (예 : RSS 피드)를 알고 있다면 Matt Gallagher의 기사 using libxml2 for XML parsing and XPath queries in Cocoa을 확인해야합니다.

+1

추가 된 문서 링크 –

+0

shouldnt NSArray * namesStartingWithB = [array filteredArrayUsingPredicate : predicate]; be NSArray * namesStartingWithB = [names filteredArrayUsingPredicate : predicate]; –

+0

@James 고개를 숙고 해 주셔서 고맙습니다. –

관련 문제