My day today was devoted entirely to working further on the tutorial I started last week; that is, the Candy Crush-like game using Swift. Today I completed Part I of the tutorial and started off on Part II. I ran into a number of bugs today that made the process a lot longer.
For example, at one point I had a strange error where a class I have been using for the entire duration of the project was no longer recognized (a call in Swap.swift claimed that Circuit was an unidentified type). I tried various things to resolve this, but the thing that worked in the end was a useful discovery. As the project is simulated various times, significant amounts of the data is stored for quicker and easier access and is not overriden when you make changes to the project. To get rid of this saved data and replace it, you can manually get rid of it (Window > Organizer) and also “clean” the project (Product > Clean). This solved the bug I had encountered before and also another problem I had faced, which was being unable to load images.
Another really useful concept I learnt about today was “extending” a preexisting type. In this tutorial, a dictionary is extended to include functionality where an input JSON file can immediately be converted into a dictionary, and this is done in a straightforward fashion: in a new file, Extensions.swift, I simply declared the extended functions within “extension Dictionary”. This concept sounds very useful for ease of coding once we get to coding our own project.
Finally, today was also a lot of with UI — as this game is like Candy Crush, only certain moves are valid, and detecting these moves and determining their validity requires implementing the functions touchesBegan(), touchesMoved(), and touchesCancelled(), which was a useful look into how Swift deals with UI. As tomorrow is implementing the rules of the game, I am sure this will require even more understanding of UI.