As defined by the swift docs, a protocol is a blueprint of methods, properties and other requirements that suit a particular task or piece of functionality. Protocols can be adopted by a class, structure and enumeration. Basically, a Protocol is a set of predefined rules that can be passed onto classes, structs and enums to follow.
Defining a protocol
We define a protocol in a similar way to what we have seen before when defining a class or other types. We use a keyword to indicate what we are defining. …
I love that you can commit and push changes to GitHub right from within Xcode. Trust Apple to keep you within their ecosystem, and their IDE! I decided to write the steps to remind myself on how to do it. I am also assuming that you have a GitHub account. If not, head over to GitHub and create one.
Classes and structs are available within the Swift language, but what are they and when would you use them?
A struct is short for structure and is used in Swift to group together a set of related data. This data is referred to as the properties of the struct. This could be an example of a person and the properties a person has.
Within a struct you can have functions, which are referred to as methods. Structs are immutable too, so once the properties are set they can’t really be changed. This can stop changes within your struct happening accidentally…
When I googled ‘magic numbers’ the first thing that popped up was the British pop band. But I’m afraid this is not what this post is about! I then specifically googled ‘magic numbers in swift’ and many questions popped up, so I thought this was a topic worth discussing. Although this isn’t specific to the Swift language, this post is relating to a swift application.
Firstly, what is a magic number, and why avoid them? A magic number is when you directly use a number (Int) in your code. Maybe the corner radius of a shape is set to 7.0…
I’m not new to problems and trying to solve them, my previous career was in the live events industry so quite often these would happen in the worst possible moments, but I am new to code related problems. Often when hitting a wall with the issue I am facing, I have found these steps have helped get me back on track.
Whether you want to see how another project is put together, or you are following a tutorial, at some stage you’re gonna want to clone a project in Xcode.
The good thing is there aren’t many steps, so it should be easy to remember!
Career changer but still a problem solver. New to Code and blogging my experiences with it. Hoping this helps both you and I learn!