Since my last post I’ve been delving deep into the code that I’ve been using from other parties. It’s a legitimate thing to do and in fact many a great developer build Frameworks and Libraries specifically for others to use (cheers!). The problems I’ve been facing the last few weeks have all come from the long standing problem facing iOS devs: whether to use Storyboards (think Film storyboards) or do things programmatically (think lines of code). There’s also a hybrid version where both are used together (in perfect harmony! I wish).
So the majority of the code I’m using from other developers is the latter whilst my code is primarily all based around Storyboards. I do appreciate the code-only versions, there’s usually pretty elegant, but for me, who sees things visually, storyboards have always been easier to see and work with. It all goes back to the fact I started with MSVC 1 (on PCs) which used connections in much the same way as Xcode Storyboards have their UI elements hooked up to underlying code. From those heady days of MSVC1 I learnt the hard way that essentially all these visual builders are doing are writing the code behind the scenes, and in the case of MSVC1 it your application crashed it often dropped you right in to this assembled code rather than your own. It can get real messy.
The other side of this coin is of course that with written code you have to rely on good naming conventions. I struggled for about a week trying to get connected code called ‘rootTabViewController’ to show content, mistakenly thinking that it was at the correct level of the navigation stack – the ‘Root’ part, when in effect some idiot (ok, me) had embedded in in another view without realising what they’d done. I should;ve really changed its name to ’embeddedTabViewController’ at that point but didn’t. What’s it they say – “Live by the Sword, die by the Sword”?
I should’ve spent some time planning this all out of course (me bad) but the good thing is that all this hacking around the other developers code has led me to have a better understanding of what it does and how to actually use it to do what I want. After that penny dropped I re-wrote about 40 lines of my own code an hey-presto, everything worked!
Picture by: Pexels