Introduction to Xcode and Swift

Apple_Swift_Logo

Logo_xcodeToday, we were introduced to the programming environment of which we will be using to create our apps. Due to previously using java in processing to create our interactive piece, I feel my programming knowledge has advanced. It was important to initially understand the similarities and differences between java and swift programming languages. Using the ‘playground’ feature in Xcode, we were able to experiment with swift and see the results immediately. A main difference was the use of ‘;’ at the end of each line of code, also declaring constants and variables, and using basic conditional statements, and for loops seemed to be simpler. Here is an example:

Screen Shot 2015-02-15 at 14.58.17

Constants are declared with the let keyword and variables with the var keyword. The value of a constant cannot be changed once it is set, whereas a variable can be set to a different value in the future.

A feature that is new in Swift is optionals, which handle the absence of a value. ‘Optionals are an example of the fact that Swift is a type safe language. Swift helps you to be clear about the types of values your code can work with’ (iOS Developer Library).
? = optional values
! = unwrap values
: = is of type

Here is an example of creating a class using swift, in this example I have created the blueprint for a person, consisting of variables: their name and age and optional gender.

Screen Shot 2015-02-15 at 15.21.42

It was important to learn the basic switch from java to swift and I think this workshop was beneficial. Understanding these basic features are essential in order for me to progress my xcode and swift knowledge further in order to create a successful ios application. From this, in each workshop we will be developing mini apps, in order to progress knowledge and advance our skills in order to be able to successfully make the app for Salisbury Cathedral.

iOS Developer Library, 2015. The Swift Programming Language [online]. Available from: https://developer.apple.com/library/ios/documentation/Swift/Conceptual/Swift_Programming_Language/TheBasics.html#//apple_ref/doc/uid/TP40014097-CH5-ID309 [Accessed 5 February 2015].

Processing Workshop – Mapping

Today, I learnt about the map function, which ‘re-maps a number from one range to another’. I used existing knowledge of importing images and the 2d pixel array formula – x+(y*width), and mapped the pixel colours of the image to a height location on the screen which is determined by the mouse. Here is the code:Screen Shot 2014-12-11 at 14.46.59Learning the map function was useful as it advances my programming knowledge, however I don’t plan on using this function in my piece. If I was to relate this mapping idea more to the brief, I would setup up a video capture so that the colour pixels of the video are mapped.

Processing (2014). Processing: Map [online]. Available from: https://www.processing.org/reference/map_.html [Accessed 28 November 2014].

Processing Workshop – Functions and Arrays

In todays workshop, I developed my processing skills and learnt about functions and colour arrays. Here is a video of what I made

Screen Shot 2014-10-27 at 14.48.23I learnt how to draw basic shapes, in this case a square an triangle in order to make the house. I then used existed knowledge of for loops and rotation in order to made the houses and ellipses rotate. I learnt how to setup an array of colours, which I did using different hex values. As well as well learning about using functions and arguments, in this case the house was the function and the arguments were the sizes and colours. I also learnt how to make the video so I clearly show on the blog what I have designed in processing.

output_qer8gM

This workshop was useful as it allowed me to develop my processing knowledge. The use of arrays is particularly useful as if I want to create an array of colours/objects for my piece then this skill will be required.