Prime?

App number 3 is now complete. Prime? is another relatively simple app that checks whether a number input is a prime number or not. I’m not spending much time on the UI appearance at the moment as i’m more focussed on developing function and learning the coding techniques. I developed a lot of new skills during the course of this mini project.

Screen Shot 2016-01-27 at 19.56.25

Initial code developed in Swift Playground

I developed some basic code using all the techniques learnt so far, utilising variables, if statements, for loops, etc (see picture above). I followed an online tutorial and even with guidance it took a while to get it working properly. In this project the aim was to develop the code first then import it into a project. I thought it might be a complicated process but it transpired to be relatively simple.

Screen Shot 2016-01-27 at 19.55.40

UI created using constraints

I’m getting used to creating simple UI’s relatively quickly and connecting it up to simple code. This time when creating the layout I utilised constraints on the interface elements, this ensures that the UI will work on all devices and stays in place when the device is rotated. The UI is simple and includes a button, text input and text output field. The aim was to take the user input and run the code when the submit button is pressed, displaying a message dependent on the result. It took a few attempts to get it working, but eventually it did. Various error messages appeared when running the code initially. To cut a long story short, I deleted a connection between the UI and code when creating the app initially and replaced it with something different, which caused various knock on effects. By deleting and resetting all the connections I got it all running smoothly on the simulator on my iPhone. Feeling proud that in less than a week I have created 3 simple apps from scratch! Just don’t type too big a number in the app 🙂

Prime? App UI

Initial code developed in Swift Playground

Prime? App UI

Prime? App UI – Portrait mode

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s