Refactor the iOS loading code.