Final interactions for project 1. I really liked creating a paper prototype before coding because it
Final interactions for project 1. I really liked creating a paper prototype before coding because it made me understand my layout better as well as the type of content I want in the app. When I began coding, I approached the app by setting up the layout I made in the paper prototype. I opened up the view controller swift files to implement by IBOutlets, IBActions and creating an array to place all of the content I want to make inside of it. I had a roadblock which was “index out of range” for the buttons and the array. For instance, when I clicked on the left button, my code was first implemented to go to the -1 position of the array which doesn’t exist. Therefore, my code would crash. In order to fix it, I set my array conditions to be strictly greater than 0 and strictly less than the array size -1 (because arrays begin at 0). When that worked, I moved on to the share button which I got helped from a youtube video (provided in my code comments). When I got the share button to work, I moved on to the like (heart) button. I wanted to place a like button in order to have more user interaction, so I took on the challenge. The like button took me the most time. At first, I searched for a heart fill and heart unfilled image, and placed them into my assets folder. I placed a IBAction button in the middle of the left and right button, and made the button begin at the heart unfilled state. I had a conditional for when the button is clicked, the heart would change to heart filled image. It changed the button to heart filled, but when I pressed the left and right button, it never changed back to the heart unfilled. It took me a couple of days to think about how I could approach this. So, I thought about my arsenal (the code I have in my swift files, and what I can do with it by learning programming languages) and took each line of code thoroughly. I decided to create another array the same size as the content (and authors) array, and set them all to false. Then, I set a conditional in the ViewController.swift file that would set the array index to true if the user clicks on the button to like the content and if it is true, keep the like button as filled. This way, when the user clicks the left and right button, and decided to go back to the content they liked, the heart would stay filled in. Similarly, if the user clicks the like button again, the array index would be set to false and the like button would stay unfilled. When I got that to work, I focused on making a tab bar connection to have a Favorites tab. When the user likes content, the same content array index would create a table view and be saved into the Favorites tab. However, I was not able to figure out how to create a customized table view. I will continue to work on this app in the future and develop it more in order to get the favorites tab to work as well as develop it more for the app store. -- source link