Introduction to Xcode and Swift


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: [Accessed 5 February 2015].

Processing Video Examples

For my interactive piece, I have analysed some examples that can be relevant towards the creation of my piece. It is important that I understand the programming language used, and that am capable of re-working it myself. There are those that program from scratch and those which hack examples together. Hacking examples together is a programming technique that some use, the advantages of this is that it is quicker and allows ideas to be more complex for those which are not that advanced in programming. However, the disadvantages are that if you don’t understand it, then mistakes can easily be made and it may be hard to resolve if the programming language is not fully understood. The advantages of programming from scratch is that it means your programming knowledge is more developed, meaning you can create complex ideas of which you can resolve errors more easily. However, the disadvantages are that it can take a lot longer as you will be writing out code that sometimes is already easily accessible to use. Therefore, if I do choose to use one of the following examples, it is important that I fully understand the code, which I will evident through the various sketches I have programmed and presented on my blog. If I decide to use one of the examples, it would just form a bit of my piece as I then need to use object orientated programming to create an array of gravitating objects, showing I have the ability to both hack and program. I will go on to analyse each example, understand and edit the code and experiment with trial and error.

Brightness Thresholdingbrightness thresholding v2

This is my favourite example, and I may incorporate it into my piece. Initially, the threshold was lower and therefore the figure isn’t that clear, however by changing the thresholding and positioning of the camera I was able to capture a black silhouette on a white background. Next, I need to go on to add objects the piece, and program it so when they reach a black pixel they move up and when they reach a white pixel they descend.

Motion Detection

motion detection v2

This example detects motion and produces a black outline around a moving figure. It works well, and I like the figure effect. However, it will be harder to program the objects as the black pixels are not as bold and clear as the example above.

Brightness Mirror

brightness mirror v2I like the effect of the grid of squares and think this looks very good and unique. Originally, the size was smaller which I don’t think worked as well, so I adjusted the size of the squares. When adding falling objects to this example, it could come across as being quite confusing and distorted but I think that this is a good back-up example that I could use.

Next, I will go on to experiment further with object orientated programming and will add an array of descending objects to the brightness thresholding example. I will experiment with different objects: shapes, figures, words or graphics, to see which works and looks best.

Shiffman, D, 2008. Learning Processing: Examples [online]. Available from: [Accessed 13 December 2014].

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: [Accessed 28 November 2014].


Pseudo-code is a informal notation resembling a simplified programming language. Pseudo-code can be applied to all programming languages and is a helpful step in order to process various ideas into code. It is a simply written, step by step structure, to help write the actual programming language. Using pseudo-code can be beneficial as it allows us to plan work more thoroughly rather than jumping straight into programming. However, it is a extra step that sometimes isn’t always necessary for advanced programers. Here is a simple example of both a flowchart and pseudo-code in order to make a cup of tea:


The steps are simple for anyone to understand and from this can be transferred into the required programming language. For my project, I am using Java within Processing and as I am not advanced in this language I could use pseudo-code in order to structure my idea and help me to transform it into code. I feel by doing this it would be beneficial, as it will help me to fully plan my idea and enable me to clearly see whether it is realistic to achieve by the deadline. By carrying out efficient planning, it can then result in a more efficient development process and means that fewer problems arise during coding. Next, I will go on to further plan out my idea and write out a basic pseudo-code for it.