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/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform
/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'"]
            orderBy:@"createddate"]
            take:5]
            toArray];

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.