Last active
December 8, 2016 18:17
-
-
Save shmidt/19b2383e69ffd19de7c5bab20a23c9f1 to your computer and use it in GitHub Desktop.
NSPredicateEditorRowTemplate subclass to support relationships in Interface Builder
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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