My first ever iOS app and the best way to learn

Hello blog, its been a while.

So today i’m going to build my first ever iOS application. Why is this something worthy of writing about? Well, as i’m sure is the same for most non-iOS developers, learning to develop iOS apps for iPhone / iPad is something i’ve wanted to do for a long time but as a web developer, just haven’t had the time to really ever make a start. After all, in the field of web development there is a constant stream of learning distractions, new tools, frameworks and languages to learn and play with as it is, and time is always short these days. However, i’m hopeful that now is the time and i thought that i would share my experience and process of doing so in case it may be useful for any other non-iOS developers looking to jump in the world of iOS apps.

The application

So let me explain why i am attempting to develop an iPad application for the first time with no previous iOS experience. I am currently working on a charity project, which has given me the opportunity to learn and develop a whole host of new and existing skills. Not being a commercial project, this process is much more enjoyable and is an ideal environment to learn and try new things.

Part of the project involves two iPads, that need a simple interface to allow visitors to view  two separate websites, the charities website and the other being the Transport for London website for travel information. So i thought, great, nice and simple, i’ll create a web app, optimised for an iPad, using HTML iframes to display each website, with a simple top bar for navigation back to a splash home screen. In my mind, there was really no need to develop a native iOS app for this…until i ran into a little problem.

See the issue is that one of the websites being linked to, has a ‘X-Frame-Options SAMEORIGIN’ header on their server which prevents other websites from embedding the website using an iFrame. And this is the problem. So it seems that the only way to achieve what we need and overcome this, is it develop a really simple native app that will load the site through use of a iOS UIWebView. Great, all sounds good, but i have never developed a iOS app before. Before i started to think of who else i can ask to do this, it dawned on me that this would be the perfect opportunity to learn.

The best way to learn

When i look back at all of the things i have learnt in web development its clear to see that the times when i have actually really fully learnt how to do something happens most when there is a real need. This is the key. There are many things that i want to learn but always never get around to achieving, either due to lack of motivation or lack of time. However, when you are presented with a real life situation that has a real need i have found the best way is too jump in at the deep end. Its amazing how much quicker we as humans can learn and understand by doing rather than just learning the theory about something.

So now i have a real need to develop a iOS app, i figure, now is the time, after all this is an ideal app to start with as its so simple, combined with the fact that we now have Swift, which is designed to be a easier language to learn compared to Objective C, this really is a no brainer.

I have one day to develop this simple app so i better get started. I will share the end result and my experience, in case anyone else is in a similar position and may find this useful.

I am going to use this great tutorial (http://iosdeveloperzone.com/2013/11/17/tutorial-building-a-web-browser-with-uiwebview-revisited-part-1/) as my basis for learning and see where we go from there.

I have a fresh install of X-Code 6 Beta and a strong reason to learn. Here we go…

Advanced Custom Fields – Setting a default for unsaved true / false options

Yesterday I was implementing a true / false option using ACF and i came across a little problem. I needed to write an if statement like this…if the option equals true then display this html.

The problem is I need the html to display by default, i.e when someone first installs the theme before saving any options, but the option value remains empty until the options are saved for the first time.

After a little bit of thinking I realised that by using ACF function get_field_object() I could use default_value field. Great…problem solved? Hmm not quite…its not as simple as this as the default_value field also isn’t set until ACF options are first saved.

So to get around this you can use a PHP empty() function as part of the conditional like below. If the default_value field is blank then we know the options haven’t of been saved yet, which is just what we need to know. Bingo.

$option = get_field_object('option_name', get_the_ID());

if (empty($option['default_value']) || $option['value'] == true) {

}

Hello World. A few words to start my blog.

Monday Jan 6th 2104. The start of a new year (well ok, i’m only 6 days late) and to co-inside with setting up my new portfolio, i have decided to start writing a blog…finally. A place to share thoughts on work, design, technology and probably some other random topics along the way. See like most people in this world, i’ve been using the internet for a long time, since a wee boy, and its done me well. Thing is though i have always been a taker and not a giver; i’m always reading blogs, downloading stuff and gaining help and inspiration from other people but i have never really shared much myself, and that should probably change.

Now let’s be frank, i don’t really expect anyone to actually read my blog of course but i figure that theres a number of worthwhile reasons to start, so here we go…now i’ve made a start let’s see how this goes.