ios-queryable is a library that simplifies writing queries in Core Data. I released it around 9 months ago, and it has become reasonably popular since then, with a hundred-something stars and a few forks on GitHub.
At this point, it’s basically a complete, working, well-tested library, and it does pretty much everything I originally set out to accomplish. However, I don’t want to simply stop working on it; I want it to grow and evolve and become even more powerful. So I’m asking you – the community – for your input. What do you want to see in it? Where do you want to see it go?
Here are some possibilities:
- Support for blocks (i.e. passing in a block to the where: method)
- More IEnumerable methods – GroupBy, Join, ToDictionary, Aggregate, etc.
- Direct Sqlite support (that is, no dependency on Core Data. Sounds like a lot of work…)
- OS X support (I’ve never done OS X-specific development, so I’m not sure what’s involved here; maybe it already works!)
- Improved error handling (since, you know, there isn’t really any at the moment…)
Do you have any other ideas, or any thoughts on these ideas? Leave a comment and let me know!
ios-queryable has seen a few improvements since it’s initial release. This is all part of my effort to make it the best wannable LINQ implementation for iOS development and Core Data.
I have added a bunch of handy new methods from IEnumerable<T>, including:
- single / singleOrDefault
and the predicate versions of first and firstOrDefault. I have also added support for parameters in where queries (and all of the other queries that support predicates) – something that should’ve been in the initial release.
Finally, IQueryable now supports the NSFastEnumeration protocol, so that you can directly read the results of queries in a foreach loop:
IQueryable* widgetQuery = [self.objectContext ofType:@"Widget"];
foreach(Widget* widget in widgetQuery)
// Do widgety stuff
As always, your feedback is appreciated (as are your pull requests!).
My current project relies heavily on Core Data. Since writing queries with Core Data really sucks, I have thrown together a little helper project called ios-queryable to ease the pain.
From the readme:
ios-queryable is an Objective-C category that provides IQueryable and IEnumerable-like functionality to Core Data.
It supports query composition and deferred execution, and implements a subset of IEnumerable’s methods, such as where, take, skip, and orderBy.
It lets you write code like this:
NSArray* widgets = [[[[[self.managedObjectContext ofType:@"Widget"]
where:@"Type == 'abc'"]
instead of like this:
NSFetchRequest* fetchRequest = [[NSFetchRequest alloc] init];
NSEntityDescription* entity = [NSEntityDescription
NSPredicate* predicate = [NSPredicate predicateWithFormat: @"type == 'abc'"];
NSSortDescriptor* sortDescriptor = [[NSSortDescriptor alloc]
NSArray* sortDescriptors = [[NSArray alloc] initWithObjects: sortDescriptor, nil];
NSArray* widgets = [self.managedObjectContext executeFetchRequest:fetchRequest error:&error];
Please send me your feedback, and keep in mind that ios-queryable is still a work in progress!
One of my goals for the year was to release some open-source Objective-C code. I am happy to say that I nave now accomplished that goal!
ReallyRandom is an Objective-C class for retrieving truly random numbers from http://random.org. It supports synchronous and asynchronous operation and offers much nicer timeouts than the standard 30 second or 240 second timeouts. I know this class might not exactly have widespread appeal, but maybe someone will find it useful one day. You can get the code from GitHub.
I wrote this class as part of my latest app, which I hope to complete by the end of April. After all, I have to live up to the ‘App Per Month’ name, don’t I?
As I am still an absolute beginner when it comes to Objective-C, I would love any feedback on coding style, best practices, and API usage.