In this lesson we begin talking about the app’s model, or data model, which is the types of data that an app deals with collectively. Different kinds of apps have different data models, each of which has its own set of types. We have been working with strings, ints, and bools a lot but in this lesson, we learn that you are not limited to the types already in swift; you can create your own types. One way to do this is by declaring a structure. A structure is a way of grouping values of other types together. Once you have declared a new type, you can then create an instance of that type. Also, when you declare a structure, an initializer is automatically created for you. This initializer has a parameter for each member property in the struct, which is called a memberwise initializer. When you begin typing the struct, the autocompletion pop-up menu will include the memberwise initializer. You can make your own structs mutable or immutable, just declare any changeable properties using var and Assign the struct to a variable, not a constant. Your own types can be passed into or out of functions, just like built-in types. A function is declared outside of the struct. A method is declared inside of the struct. Structures are a better way to define data because you can organize data together instead of declaring a series of variables.
For further actions, you may consider blocking this person and/or reporting abuse
Top comments (0)