Monthly Archives: October 2014

Loading a view from a XIB

Ever since they where introduced I’ve been a huge fan of using storyboards in Xcode. Storyboards gives you a great overview of the flow in an app and in some cases even replaces the need of a separate mockup tool. But storyboards also have a huge disadvantage; By being stored in a single file it’s practically impossible to have several developers working on the same storyboard file at the same time. It is also rather cumbersome to reuse views and components in other projects when they are embedded in a storyboard file. All of this has made me go back to using single XIB-files again. XIB-files gives you a lot more flexibility and you can have XIB-files for all sorts of UI-components if you like.

But XIBs has their issues to. For example, I think it looks rather messy to load your UI components like this:

In order to getter a little bit cleaner code I packed this functionality up in a category like this:

Then by importing this category and make sure you’ve named your XIB files the same as your classes you can now get a little bit cleaner code.

Unity: Start with selected scene

Sometimes when you test your code in Unity you really need to start from a specific scene. There is no way (that I know of) to get Unity to do this for you, but since it’s really simple to extend the editor with your own code I wrote a simple script that saves the current scene and loads a menu scene before running. When you’re done testing, you run the same method again and your last scene will be loaded for you.

Thank you, Unity for making my life so easy!