Coding When You Can

I think I may need a new blog theme. I set this site up super quickly – prior to this, I was trying to get my personal website set up with Hugo and I spent hours doing what was supposed to be a super easy install (yes there was some learning curve with Git and the Mac command line for this Windows girl). I then ran into issues with my hosting and thought you know what, screw it. This is taking up way too much time, and I’m here to learn how to code iOS apps, not to use Hugo for my personal website. So I went with my old familiar friend WordPress, picked out a free theme in about 2 minutes, and here I am. What I was getting at here is that I hate that the blog looks like crap unless I put a picture in the post! I mean, how many selfies can I take with my computer before it’s just boring for everyone?!

Tonight I decided to get behind the keyboard for a little while, even though it’s late and it’s Sunday and I’m up against giving my daughter her bath and bedtime routine. It seems like with my schedule, I can only spend time coding every couple of days. I think the important thing is not the frequency, but just the fact that I keep coming back to it. I’m a very determined person, and I am determined to make time for this and to see it through. The wheels in my mind are already churning about what my first app is going to be. I’m going to keep it very simple at first, but I’m excited. And I’m already kind of “over” the demo app. Is that terrible to say? I just want to care about what I’m developing, and I do not care about a food tracker. I’ve never tracked food a day in my life!

However I think I’m going to complete the tutorial. I’m about halfway done, and what’s left is back end stuff – defining a data model and actually saving the food ratings and displaying them back to the user.

Today I worked on the ratings control of my demo app. I learned how to add images to the Assets folder, how to style those images, and how to use the star rating in various selection states (highlight, empty, filled, cleared) based on the user’s actions. When a user uses the ratings control, I now have the selectedRating tracking a number behind the scenes. I also learned about property observers, although I don’t really understand them yet.

So next time I work, I’ll define a data model. I’m interested to see how this works, since my prior experience is with a SQL backend. That’s it for today! I’m off to go wash dishes then give my toddler a bath…#momlife

PS – I recently ran a SEO business and the minimum ‘good’ blog post length for SEO purposes is 1,000 words. It’s giving me some kind of enjoyment to write such a short posts, knowing that I am doing this just as an outlet for myself, not to hit some kind of magical word count or keyword score. Short blogging is so much easier 😉

Day 2: #MomLife and Layout Issues

**In case you missed my other posts, I’m currently working through this tutorial from Apple, where I’m making a food tracking app.

I tried to spend a couple hours coding yesterday morning, but instead ended up with a lot of frustration, due to this:

Ok, I don’t look annoyed here. But truth be told, I was.

That’s me, sitting in front of my computer, with my daughter all up in my grill. She was having a very needy day yesterday, and it did not jive well with me trying to do something that requires my full attention, like learning Swift. So I ended up frustrated and just called it quits for the day after getting through about 1/4 of 1 page of my tutorial. I slogged through it but because of all of the distractions, I couldn’t even really tell you what I did. Toddlers and learning to code don’t mix, let me tell you!

So today was a new day, and my parents took my daughter to the Children’s Museum. Yay, uninterrupted time to code!

Today I worked with view controllers so that a user can tap a placeholder image, choose an image from their photo library, and submit it with his/her meal rating. I was also introduced to the world of gesture recognizers, in this case a tap gesture. I also created an image picker: I learned how to bring up the photo library, how to disable the camera, and how to dismiss the picker once a user chooses an image.

All of this went pretty smoothly. I followed the directions in the tutorial and got the results as expected. By the end of it, I was able to replace the default image with one I chose from my simulator’s camera roll.

The next piece of the app is to implement a custom control: a ratings control that is made up of stars, where the user can choose a star rating between 1 and 5. I’m only about halfway through this section. Every time I scroll down a bit on the tutorial it just seems to get longer and longer! The tutorial tried to explain what a view is, but I ended up googling it to get a better idea. It seems like I’m adding a new stack view so that I can place the 5 rating buttons on my storyboard.

The tutorial also had me write up some initializers, but I don’t understand what I’m doing with those, I just copied what the tutorial said. If I took the time to fully understand every single thing I typed, I’d never get through the tutorial. I know that eventually I will need to understand that concept, but for now, I’m OK with blowing past some stuff for the sake of accomplishment.

In this section, I wrote my first loop in Swift! I remember loops well from C# and they are a universal programming concept. The loop was used to create 5 star buttons (I originally started with one). So far, when I tap the star rating, I’m getting a console printout of “Button Pressed”. Further along in the tutorial we will actually assign values to the buttons and save those, but I’m not there yet.

I’ve been noticing that something is “off” with my storyboard layout, and I have a feeling it has something to do with the constraints I assigned to my labels, text inputs, and image. I remember that at one point the tutorial had me group all of them together and then they will stay together. I also added constraints on the image to make sure it’s always a square. But somewhere along the way, things started looking like a hot mess compared to the tutorial:

Tutorial on the left, my app on the right


The app still functions as the tutorial says it should, so I’m not overly worried about the layout issues for now. Somehow my “Enter Meal Name” text input got way too large and so did my “Set Default Label Text” button. I tried to manually change their heights but it only caused problems because they are grouped together and have constraints. Still more to be figured out here, for sure. I also added a default image of food, where the tutorial has a different default image (“No photo selected”). So the content of that one really isn’t a problem, just the size.

I feel that many aspects of this tutorial are over my head, and as I mentioned earlier, I’m not fully understanding what I’m typing. I think that’s just the way of learning though, sometimes you have to DO before you can fully understand down the line. Here’s to continued learning!