Closed kylef closed 11 years ago
I really like this. I'll check out mogenerator. If we can find a clean way to do it, it'll work a treat!
This is a great idea.
In addition, exposing the attribute methods will help when creating predicates with multiple conditions. For example:
NSPredicate *predicate = [NSPredicate predicateWithFormat:@"%@ == @'Andy' AND %@ >= 10", [Person name], [Person age]];
There is also NSCompoundPredicate
[NSCompoundPredicate andPredicateWithSubpredicates:@[
[[Person name] equals:@"Andy"],
[[Person age] greaterThanOrEquals:@15],
]];
We could also have a wrapper around some things in NSCompoundPredicate.
@interface NSPredicate (KFData)
- (NSCompoundPredicate *)not;
- (NSCompoundPredicate *)and:(NSPredicate *);
- (NSCompoundPredicate *)or:(NSPredicate *);
@end
I really hate creating sort descriptors and predicates because you often have to write the same thing. You can also hit issues later because of use with strings.
Entity
Implement either a category or on the entity class. Perhaps we can have some tool to generate these. I see http://rentzsch.github.io/mogenerator/ https://github.com/rentzsch/mogenerator/ being used a lot.
Equals
Sort descriptors
Number based comparisons
I've created this as an issue for discussion, what do you think?
/cc @calvincestari @iamandybarnard