Ios-queryable Improvements

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:

  • all
  • single / singleOrDefault
  • any
  • count

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!).

I hate it when a header file “has been modified since the precompiled header was built”

One of my favourite blog topics is poking fun at Xcode and all of the bizzare problems I encounter with it. The most recent one was a compiler error that looked like this:

fatal error: file '/Applications/
/Developer/SDKs/iPhoneSimulator6.0.sdk/usr/include/Availability.h' has been modified since the precompiled header was built

Strange, right? Fortunately, it was an easy fix – all I had to do was a Clean. After that, it compiled correctly.

What boggles my mind is that Xcode knew exactly what was wrong, but wasn’t smart enough to fix the problem itself. Maybe I am being unrealistic here, but it seems to me that a file included in the precompiled header has changed, the correct behavior would be to, you know, recompile the precompiled header?

Then again, it’s Xcode. So I guess not.

ios-queryable – IQueryable and IEnumerable for Core Data

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
                               entityForName:@"Widget" inManagedObjectContext:self.managedObjectContext];
[fetchRequest setEntity:entity];

NSPredicate* predicate = [NSPredicate predicateWithFormat: @"type == 'abc'"];
[fetchRequest setPredicate:predicate];

NSSortDescriptor* sortDescriptor = [[NSSortDescriptor alloc]
                                    initWithKey:@"createddate" ascending:YES];

NSArray* sortDescriptors = [[NSArray alloc] initWithObjects: sortDescriptor, nil];
[fetchRequest setSortDescriptors:sortDescriptors];

[fetchRequest setFetchLimit:5];   
NSError* error;
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!

The App Buying Experience

I recently attempted to purchase an app from the app store on my iPhone, and I must say, the experience was quite hilarious. Here is a rough overview of the process (from memory, so apologies if a few details are off):

  1. Tap the price
  2. Tap buy
  3. Enter my password
  4. Get prompted to enter in three security questions
  5. Tap not now
  6. Wait a while, notice that nothing is happening
  7. Tap buy
  8. Tap OK when prompted to enter in my security questions
  9. Select my questions and answers
  10. Tap ok
  11. Tap buy
  12. Get prompted to verify my credit card into
  13. Tap continue
  14. Enter in my credit card info
  15. Tap done

And there you have it – buying apps in only 15 easy steps!

I was going to make a snarky comment about how Apple should license Amazon’s one-click buying patent, but apparently they already have. Joke’s on me.

Using an App Analytics service? You are violating Apple’s developer agreement

I’ve been looking into third-party app analytics services such as Mopapp and appFigures for a while now. There’s something that worries me about these services, though: they ask for your Apple ID and password.

Wait, what? Are you sure this is a good idea? Am I even allowed to give out this information? I’m not sure, so I decided to check. And here it is, straight from the horse’s mouth – Section 1 of Apple’s developer agreement (emphasis mine):

 The Apple ID and password you use to login as a Registered Apple Developer cannot be shared in any way or with any one. You are responsible for maintaining the confidentiality of your Apple ID and password and for any activity in connection with your account.

That seems pretty cut-and-dry. Sharing your login information is a violation of the agreement. So what’s the deal? Is it only ‘sharing’ if I give my login info to a person? Do we simply ignore the issue because these third-party analytics services are so useful?

Considering that you can get banned from the app store for violating the developer agreement, this seems like a pretty serious matter. Granted, fraud might be a completely different level of violation than sharing your login info, but given Apple’s history of somewhat arbitrary decisions, I’m not sure that I want to risk it.

What do you think?

iOS App Postmortems – Gym Calculator

Gym Calculator is now available on the app store.

This will be a rather short postmortem as it’s such a small application. But don’t worry, I have some things in the pipeline that will warrant much longer ones…


Gym Calculator is an app that does the math for you when you are at the gym. It lets you quickly add up your plates to figure out how much weight you are doing. You can also give it a target weight, and it will tell you exactly what plates to put on the bar to achieve it.

Development Time:

~7 hours.

Review Time (time spent in the iOS app submission queue):

9 days.

New technologies I learned and used:

There wasn’t anything particularly new here. I guess the most notable new ‘technology’ was that Gym Calculator was the first app I created from the ground up with the 4″ iPhone in mind.


The main challenges were not implementation issues, but small-scale design decisions. For example, the app supports conversion between pounds and kilograms, but metric and imperial olympic weight sets are different. Should a 45lb bar convert to a 20.4 kg bar (the mathematical equivalent), or to a 20 kg bar (the real-world equivalent)? I chose the latter.

Future plans:

Aside from bug fixes,  I don’t see too much development happening on Gym Calculator in the future. It’s such a small app that there’s not really too many other things I could do with it.