Day 1: Jumping in with Xcode

I decided to sit down and spend a few hours starting to learn Xcode (the IDE for iOS) and Swift (the programming language for iOS apps) for day 1 of my self-taught learning experience. But where to begin? I knew a Google search would be overwhelming. Judge this however which way you want, but I wasn’t ready to lay down any cash for paid lessons or content. I started by reading the Swift documentation but before I knew it my eyes were glazed over.

My husband Tim is a developer, and he asked me a good question: why are you starting with the low level stuff? Why not start at a higher level, then learn syntax as you need to? Logical, logical Tim. But he was so right. He sent me a couple links. I started with this article on medium. It gave me a high-level lay of the land. Then I started on this tutorial right away, straight from Apple. I’d much rather actually create something than just read about creating something, so yay. I downloaded Xcode from the app store and got started with the tutorial right away.

I got through building the UI without much issue. The storyboard in Xcode was easy to use (it’s just a GUI) and with the tutorial telling me every single step….wait, I did notice that the tutorial is for an older version of Xcode. Some of the menu items, detail panels, etc are different than what the tutorial says, but I found my way around just fine.

The second section was about connecting the UI with code. Unlike the first section, this part required me to write some code. Woot, day 1, I am coding again! Maybe you can teach an old dog new tricks, suddenly my past life as a developer seemed like it was just yesterday. Except I did keep putting a semicolon after each line…that’s a C# habit. So I was churning through the tutorial, stopping when it told me to to make sure it worked, and it always did. Until it didn’t. I got to the end of the second section in the tutorial, brought up the simulator, and expected to see the app work. When I clicked a button, nothing was happening. The text in the input box was supposed to replace the text of a label above the input box. Instead I kept getting an unhandled exception and the app just went blank.

I started out by googling the exception, and a lot of the results were about a memory leak. Hmm, that didn’t seem very likely to me. This was a really simple app. My past experience tells me that googling an exception will not always send you down the path of finding the right answer. Usually it’s something a lot more obvious.  So I went back through the tutorial with a fine toothed comb. I found one line where I left a semicolon, I thought that was the issue – but nope. I took it out and still had the exception.

I ended up opening the demo code from Apple and comparing it to mine line by line – STILL nothing! I had nothing wrong in my code, so what the heck was the problem?! This is where I started to get frustrated. Coding requires so much patience. Sometimes you spend hours untangling something so simple – but that’s how you learn. So I knew this was a great learning experience, but that doesn’t make it any less frustrating.

A few hours later I realized that for one of my labels on the storyboard, instead of control + dragging it to the ViewController file, I just typed in the code that was auto-generated by doing that same action. I incorrectly assumed that control + drag only wrote the line of code. Apparently it also makes an output association behind the scenes with the storyboard.

Today’s lesson learned: there is stuff being done behind the scenes in XCode when you use the storyboard that you can’t shortcut with a line of code (at least not within my limited understanding).

Whew. Here’s to less frustrating (yeah, right!) days ahead.

My coding setup in the RV. The pink marble thing is my laptop, and I have a big monitor.

 

Leave a Reply

Your email address will not be published. Required fields are marked *