My employers at Vokal Interactive have been kind enough to let me use my downtime to tackle of one of my biggest irritations with the new Asset Catalogs in Xcode 5: The fact that you still have to use the fragile imageNamed:
system to call images in code.
With the consultation of some co-workers and other friends, I put together Cat2Cat – Catalog to Category, a simple command line utility which walks through your asset catalog and spits out a category on UIImage that allows you to programmatically access your images through class methods.
The easiest way to use it is to download the compiled binary and set up an aggregate target with a run script like I set up in the sample iOS app, which is included at the GitHub repo. It re-writes the entire category file every time you run the target, updating it with all your new and changed image names.
The benefits of this approach are mostly outlined in the ReadMe, but the tl;dr of that is:
- No more missing images because of typos
- Auto-complete when accessing images
- Warnings when your image names collide
- Instant heads up of where you need to change your image names after running the script
If you find it useful, please feel free to share it far and wide.
Pingback: Fun with Work Downtime: Cat2CatVokal Interactive | Vokal Interactive