Tuesday, 31 January 2012

AudioToolbox.framework missing required architecture i386 in file

"AudioToolbox.framework/AudioToolbox, missing required architecture i386 in file"

Had this error today when building to iPhone 5.0 Simulator. I fixed it simply by removing and re-importing the AudioToolbox framework into the project.


Friday, 27 January 2012

iPhone keyboard - hide when done

Ever got stuck in a form using an iPhone app? You've edited a text field but you're left with the keyboard hiding the form submit button. I have, and its bloody annoying (most recently in the otherwise excellent pixlr-o-matic app), and it almost feels like some fundamental Apple design flaw. But you should blame the developer, because what he/she forgot to do was tie an action to the text field's 'Did End On Exit' event.

The keyboard hiding method declared in the action just needs to do one thing - resign the text field as first responder, like so:
[yourTextField resignFirstResponder];
And, to make things even better for your user, change the return key to 'Done' in your Attributes Inspector.

And even better still, create a big invisible custom button behind all your other controls and attach it to your keyboard hide method too. This will comply with the common convention that a touch outside of any controls kills the keyboard.

Tuesday, 24 January 2012

Return user to paginated list page after delete or edit event

The easy way to send your users back the same list page (page number, ordering) they were on prior to selecting an item for edit (or deleting it non-ajax style with full postback) is to store the referring path in session and redirect to it when the task is done, like so:
def destroy #or whatever you're handling
  session[:return_to] = request.referer
  #do whatever you need to do here
  redirect_to session[:return_to]

Friday, 20 January 2012

Regular expression regex for validating email addresses

I've seen a few of these in my time, but this one has been serving me well...found in Michael Hartl's Rails book:

Wednesday, 18 January 2012

Using the Visual Studio 'Consolas' font in RubyMine

The default font in Visual Studio 2010 is the lovely 'Consolas'. So lovely in fact that I wanted it on my Mac, specifically for my Rails IDE, RubyMine. After a little googling I found the answer here.

The gist of it is
  • Download the Open XML File Format Converter for Mac
  • Open its contents, and find and install the package 'OpenXML_all_fonts.pkg'