Skip to content

Instantly share code, notes, and snippets.

@shmidt
Last active December 8, 2016 18:17
Show Gist options
  • Save shmidt/19b2383e69ffd19de7c5bab20a23c9f1 to your computer and use it in GitHub Desktop.
Save shmidt/19b2383e69ffd19de7c5bab20a23c9f1 to your computer and use it in GitHub Desktop.
NSPredicateEditorRowTemplate subclass to support relationships in Interface Builder
class RowTemplateRelationshipAny: NSPredicateEditorRowTemplate {
override func predicate(withSubpredicates subpredicates: [NSPredicate]?) -> NSPredicate{
let predicate: NSComparisonPredicate = super.predicate(withSubpredicates: subpredicates) as! NSComparisonPredicate
let newPredicate = NSComparisonPredicate(leftExpression: predicate.leftExpression, rightExpression: predicate.rightExpression, modifier: .any, type: predicate.predicateOperatorType, options: predicate.options)
return newPredicate
}
}
class RowTemplateRelationshipAll: NSPredicateEditorRowTemplate {
override func predicate(withSubpredicates subpredicates: [NSPredicate]?) -> NSPredicate{
let predicate: NSComparisonPredicate = super.predicate(withSubpredicates: subpredicates) as! NSComparisonPredicate
let newPredicate = NSComparisonPredicate(leftExpression: predicate.leftExpression, rightExpression: predicate.rightExpression, modifier: .all, type: predicate.predicateOperatorType, options: predicate.options)
return newPredicate
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment