October 2017
Intermediate to advanced
210 pages
5h 32m
English
In object-oriented programming, we cannot create an object without a blueprint that tells the application what properties and methods to expect from the object. In most object- oriented languages, this blueprint comes in the form of a class. A class is a construct that allows us to encapsulate the properties, methods, and initializers of an object into a single type. Classes can also include other items, such as subscripts; however, we are going to focus on the basic items that make up classes not only in Swift, but in other languages as well.
Let's look at how we would use a class in Swift:
class MyClass {
var oneProperty: String
init(oneProperty: String) {
self.oneProperty = oneProperty
}
func oneFunction() {
}
}
An instance of ...
Read now
Unlock full access