2010-04-23 5 views

답변

2

NSPredicate는 평가할 때 true 또는 false를 리턴하므로 "a"로 시작하는 모든 단어를 리턴하는 술어를 작성할 수 없습니다. 당신은 "A"로 시작하는 단어가 true를 돌려 술어를 만들 수 있습니다

후 세계에 문장을 분할하고, 같은 조건 뭔가 좋은 단어를 필터링 :

NSArray *words = [sentence componentsJoinedByString:@" "]; 
NSPredicate *beginsWithA = [NSPredicate predicateWithFormat:@"SELF beginswith[c] 'a'"]; 
NSArray *wordsBeginsWithA = [words filteredArrayUsingPredicate:beginsWithA]; 
관련 문제