문제

핵심 데이터 관리 객체 모델에는 BAZ라는 엔터티 BAZ와의 관계 (To-Many 역)와의 관계가있는 엔티티 FOO가 있습니다. BAZ에는 "tag"이라는 문자열 속성이 있습니다. 내가 사용할 때 [NSPredicateRowEditorTemplate templatesWithAttributeKeyPaths:[NSArray arrayWithObject:@"baz.tag"] inEntityDescription:FooDescription] nspredicateeditor의 행 편집기를 만들려면 결과에는 다음과 같은 행 템플릿이 포함됩니다.

팝업 : baz.tag] [팝업 : 포함 | is | is | ...] [textfield

팝업에서 "포함"을 선택하면 술어가있는 쿼리가 예상대로 작동합니다. 다른 팝업 (예 : "IS")을 선택하면 다음과 같은 오류가 발생합니다. "여기서는 허용되지 않습니다." 사용해도 되나요 [NSPredicateRowEditorTemplate templatesWithAttributeKeyPaths:inEntityDescription:] 아니면 행 편집기를 수동으로 빌드해야합니까?

도움이 되었습니까?

해결책

자동으로 생성 된 템플릿처럼 보입니다 (사용 [NSPredicateRowEditorTemplate templatesWithAttributeKeyPaths:inEntityDescription:]) 올바른 연산자를 생산할 수 없습니다. 솔루션은 수동으로 템플릿을 작성하는 것입니다 [NSPredicateEditorRowTemplate initWithLeftExpressions:rightExpressionAttributeType:modifier:operators:options:]. 주어진 예제 :

id template = [[NSPredicateEditorRowTemplate initWithLeftExpressions:[NSArray arrayWithObject:[NSExpression expressionForKeyPath:@"baz.tag"]] rightExpressionAttributeType:NSStringAttributeType modifier:NSAnyPredicateModifier operators:keywordOperators options:0];
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top