Skip to content

Instantly share code, notes, and snippets.

@abock
Last active December 14, 2015 09:38
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save abock/0493449d133be0caeb60 to your computer and use it in GitHub Desktop.
Save abock/0493449d133be0caeb60 to your computer and use it in GitHub Desktop.
//
// Using the generated constructors, lots of ugly:
//
FilterEditor.RowTemplates = new [] {
new NSPredicateEditorRowTemplate (new [] {
NSNumber.FromUInt32 ((uint)NSCompoundPredicateType.And),
NSNumber.FromUInt32 ((uint)NSCompoundPredicateType.Or),
NSNumber.FromUInt32 ((uint)NSCompoundPredicateType.Not),
}),
new NSPredicateEditorRowTemplate (
new [] { NSExpression.FromKeyPath ("Platform") },
new [] {
NSExpression.FromKeyPath ("Lion (10.7)"),
NSExpression.FromKeyPath ("Mountain Lion (10.8)")
},
NSComparisonPredicateModifier.Direct,
new [] {
NSNumber.FromUInt32 ((uint)NSPredicateOperatorType.LessThan),
NSNumber.FromUInt32 ((uint)NSPredicateOperatorType.LessThanOrEqualTo),
NSNumber.FromUInt32 ((uint)NSPredicateOperatorType.GreaterThan),
NSNumber.FromUInt32 ((uint)NSPredicateOperatorType.GreaterThanOrEqualTo),
NSNumber.FromUInt32 ((uint)NSPredicateOperatorType.EqualTo),
NSNumber.FromUInt32 ((uint)NSPredicateOperatorType.NotEqualTo)
},
NSComparisonPredicateOptions.None
),
new NSPredicateEditorRowTemplate (
new [] { NSExpression.FromKeyPath ("C# Type") },
NSAttributeType.String,
NSComparisonPredicateModifier.Direct,
new [] {
NSNumber.FromUInt32 ((uint)NSPredicateOperatorType.BeginsWith),
NSNumber.FromUInt32 ((uint)NSPredicateOperatorType.Contains),
NSNumber.FromUInt32 ((uint)NSPredicateOperatorType.EqualTo),
NSNumber.FromUInt32 ((uint)NSPredicateOperatorType.EndsWith),
NSNumber.FromUInt32 ((uint)NSPredicateOperatorType.NotEqualTo)
},
NSComparisonPredicateOptions.None
)
};
//
// Hot convenience constructors save your wrists and brain!
//
FilterEditor.RowTemplates = new [] {
new NSPredicateEditorRowTemplate (
NSCompoundPredicateType.And,
NSCompoundPredicateType.Or,
NSCompoundPredicateType.Not
),
new NSPredicateEditorRowTemplate (
"Platform",
new [] {
"Lion (10.7)",
"Mountain Lion (10.8)"
},
new [] {
NSPredicateOperatorType.LessThan,
NSPredicateOperatorType.LessThanOrEqualTo,
NSPredicateOperatorType.GreaterThan,
NSPredicateOperatorType.GreaterThanOrEqualTo,
NSPredicateOperatorType.EqualTo,
NSPredicateOperatorType.NotEqualTo
}
),
new NSPredicateEditorRowTemplate (
"C# Type",
NSAttributeType.String,
new [] {
NSPredicateOperatorType.BeginsWith,
NSPredicateOperatorType.Contains,
NSPredicateOperatorType.EqualTo,
NSPredicateOperatorType.EndsWith,
NSPredicateOperatorType.NotEqualTo
}
)
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment