I have four main methods:
+ (NSArray *)findAll;
+ (NSArray *)findAllWithOrder:(NSArray *)order;
+ (NSArray *)findAllWithConditions:(NSDictionary *)conditions;
+ (NSArray *)findAllWithLimit:(NSRange)limit;
In addition, I want to combine these methods (so I can find all by both order and conditions, for example). Currently I’m doing (all possibilities even with arguments in a different order not shown here):
+ (NSArray *)findAll;
+ (NSArray *)findAllWithOrder:(NSArray *)order;
+ (NSArray *)findAllWithConditions:(NSDictionary *)conditions;
+ (NSArray *)findAllWithLimit:(NSRange)limit;
+ (NSArray *)findAllWithOrder:(NSArray *)order conditions:(NSDictionary *)conditions;
+ (NSArray *)findAllWithOrder:(NSArray *)order limit:(NSRange)limit;
+ (NSArray *)findAllWithConditions:(NSDictionary *)conditions limit:(NSRange)limit;
+ (NSArray *)findAllWithOrder:(NSArray *)order conditions:(NSDictionary *)conditions limit:(NSRange)limit;
But is there a simpler way than creating dozens of methods for this? That would be very nice. Thanks.
Nope, that’s the way you do it. I’m sure someone could find ways to get around creating dozens of similar methods, but they are very rarely used. It’s pretty common for Obj-C (esp. Cocoa) objects to have large numbers of methods that differ from each other only slightly.