지금 잠시 동안 NSDataDetector
클래스를 이해하는 데 어려움을 겪고 있습니다. 설명서를 읽었지만 이해할 수는 없습니다. 내가하는 모든 일은 오류가 있음을 Xcode에 알려줍니다.NSDataDetector가 문자열의 이름을 검색했습니다.
나는이 시도로 내가 올바른 길을 가고 있다고 느낍니다. 문자열에 이름을 찾는 간단한 기초 프로그램을 작성하려면 어떻게해야합니까?
NSError *error = nil;
NSDataDetector *detector = [NSDataDetector dataDetectorWithTypes:NSTextCheckingTypeAddress error:&error];
NSString *string = @"(555) 555-5555/Nick";
NSArray *matches = [detector matchesInString:string
options:0
range:NSMakeRange(0, [string length])];
for (NSTextCheckingResult *match in matches) {
if([match addressComponents] // contains NSTextCheckingNameKey){
// do this
}
}
마지막에 물음표와 함께 문장을 넣으십시오. – danh
거기 가서 내 좋은 선생님. –
데이터 감지기는 이름이 아닌 주소 나 전화 번호를 찾습니다. 이름의 목록이 유효합니까, 아니면 이름이 항상 전화 번호 + 슬래시 또는 그와 비슷한 이름을 사용한다는 것을 알고 있습니까? – danh