A few more Default.PNGs for the archive

Here is my archive of Default.png and Default@2x.png images. There are currently three different layouts. I will be adding to the collection as I create different ones for my apps. The archive contains regular images and @2x images.

Download the Default.png archive

A UITableView with a navigation controller:

 

A grouped UITableView with a navigation controller

A UITableView with a navigation controller and a tab bar:

 

Feel free to use these images in your apps. Enjoy!

Creating NSManagedObject Subclasses – So Handy, Yet So Strange

If you are a Core Data user, you’ll likely become intimately familiar with NSManagedObject and the Core Data model editor.

One aspect of NSManagedObject is the the creation of NSManagedObject subclasses. The only way I have found to (automatically) do this is to select your entities, then go to Editor -> Create NSManagedObjectSubclass.

Why on earth is ‘Create NSManagedObject Subclass’ a global menu item? And why is it in the ‘Editor’ menu? Whose brilliant idea was it to have a global menu item for something so incredibly specific to a particular portion of a particular screen? Why is generating code from your Core Data model so completely non-discoverable? Why isn’t there a ‘Create NSManagedObject Subclass’ button right next to the ‘Add Entity’ button?

And those are just my issues with the placement of the functionality. So aside from that, how well does it actually work?

In my limited usage so far, I would say that it’s marginally useable.

First of all, having to perform a manual process in order to keep your data model and your object model in sync is pointless. By contrast, when you edit an Entity Framework EDMX file or a LINQ to SQL DBML file, your object model classes are automatically regenerated. And hey, if you’re using EF Code-First, there’s nothing else you need to do!

Second, the code generation itself seems… inflexible. As far as I can tell, there is absolutely nothing remotely similar to .TT files in Xcode/Core Data. For those unfamiliar with the Visual Studio world, a .TT file is essentially a template that can describe, among other things, how classes are generated from a data model. You can customize a .TT file so that the generated classes look exactly like you want them to – add in validation attributes, extra fields, property change notifications, and so on. This standard functionality in EF/VS, but doesn’t seem to exist in Xcode.

In order to something similar, it appears that you need a third-party tool such as mogenerator. Now it’s great that such a tool exists, but it’s sad that it needs to exist. Customization of generated code is a pretty basic IDE feature these days, and it’s yet another area where Xcode falls short of the competition.

On another code generation note, it’s quite amusing that Xcode can’t even remember what group I previously added the NSManagedObject subclasses to, forcing me to manually select it every time I change my data model.

iOS App Postmortems – Which Episode?

Which Episode? is now available on the app store, and that means it’s time for another postmortem.

Development Time:

  • ~8h

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

  • 9 days

New technologies I learned and used:

  • The only real new thing here was iOS 5’s handy NSJSONSerialization class, which is used to look up your TV shows and download posters form them.

Challenges:

  • The biggest problem here was figuring out where to get posters of TV shows. After initially settling on http://www.imdbapi.com/, I became unhappy with the (movie-centric) quality of the results, and the inability to retrieve more than one image in case of multiple shows with the same name.
    So after looking around for quite some time, and being continuously disappointed in either the licensing or the technology of each particular solution, I stumbled across http://trakt.tv and their ridiculously awesome API. Problem solved!

Future plans: The main change that will likely be coming in the future is the ability to browse between different images for your shows, just in case the default image is for the wrong show. For an example of where this would be handy, try searching for ‘Angel’. You won’t get a show about vampires.

Aside from that, the application does everything I want it do do, and aside from user requests, it likely won’t get too many more features. So as always, please let me know if there’s anything you would like to see in it!

iOS Pain Points – The Prevalence of Magic Strings

One thing I’ve noticed while working with iOS is that magic strings seem to be quite common.
They’re in Core Data:

[NSEntityDescription insertNewObjectForEntityForName:@"Foo" inManagedObjectContext:context];

They’re in Storyboards and View Controllers:

[self.storyboard instantiateViewControllerWithIdentifier:@"SomeViewControllerIdentifier"];

They’re in Segues:

[self performSegueWithIdentifier:@"SomeSegueIdentifier" sender:self];

They’re in sorting:

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

They’re in the instantiation of table cells:

static NSString* CellIdentifier = @"Cell";
UITableViewCell* cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];

Coming from the C# world of lambdas, generics, first-class enums, and strong typing, I find all of this incredibly bizzare. But hey, who needs refactorability and type safety when you can use strings!