You will be walked through the steps to create a simple Hello World App.
Once you have gone through the walkthrough please read through the sections below to make sure you have a full understanding of the content.
Naming Conventions:
Naming conventions are really important. It will form part of your Rubric for your SAC and SAT, but probably more importantly, it makes it easier for everyone if they can understand your code and what it is meant to be doing.
You will have noticed that when we made the Hello World App, you were asked to name your Buttons btnShow and btnHide. The label names lblShow.
This way of naming is a combination of Camel Case and Hungarian Notation. Hungarian Notation is putting the data type (which we will come to later) or object abbreviation at the start to identify it. The Camel Case refers to using a capital for the second part of the name that should describe what the object or variable is doing.
Auto Layout and Constraints:
One of the things you might have noticed is that if you run the App on your device or even a different simulator it actually looks different. The is simply due to the screen size. We can fix this using constraints. It is reasonably easy for this task, but as your apps interface become more complex, so too does the complexity of auto layout and constraints.
Lets have a go at getting the auto layout working for our Hello World app.
Comments:
Comments in code are used to describe what is taking place in the code directly underneath it.When you execute the code, any comments are ignored by the compiler.
In Swift, everything that starts with // will be ignored. It should also turn green in Xcode to indicate it is a comment.
Xcode automatically adds some comments to your code as seen below. You will need to add to it as you go.
I would like you to now go back into your Hello World Application you just made and comment your buttons and labels.
Comentários