iOS(MVC and swift part 1)

iOS(MVC and swift part 1)

memorize.aimemorize.ai (lvl 286)
Section 1

Preview this deck

how to deal with optionals

Front

Star 0%
Star 0%
Star 0%
Star 0%
Star 0%

0.0

0 reviews

5
0
4
0
3
0
2
0
1
0

Active users

0

All-time users

0

Favorites

0

Last updated

6 years ago

Date created

Mar 1, 2020

Cards (10)

Section 1

(10 cards)

how to deal with optionals

Front

if a = b or a = b!

Back

how to protect api for proper use?

Front

use assert(a > 0,"error message explainition") use access control keywords

Back

Explain Model-View-Controller (MVC)

Front

Back

what are the keywords for access control?

Front

internal(default, visible across the app or framework) private: visible to the class private(set): only the class can modify it fileprivate: visible to the file public: visible to the outside of the framework open: outside the framework can subclass good practice: try private initially. remove private when it is ready to be used by other code in your app.

Back

Do instance variables have to be initialized?

Front

yes

Back

What is computed property?

Front

a property with get or/ and set. used when it can be derived from other properties. It is not a stored property. If don't provide set, it is a read-only property. e.g.: var x = 1 var test: Int{ get{ return x * 2 } set(newValue) { x += newValue } } print("test get 2: \(test)") print("test set: prev x 1: \(x)") test = 1 print("x 2: \(x)")

Back

class vs struct

Front

class: inheritance and pass by reference struct: no inheritance and pass by value(only copy when modified)

Back

what is property observer?

Front

A piece of code that's called every time a property's value is set that's used to observe and respond to changes in the property's value. e.g.: Var num = 0 { didSet{ button.setTitle("\(a)") } }

Back

What is extension

Front

add new properties and methods to the existing class/ struct/ Enum. restriction: (1)only add new properties or methods. Can't change existing one. (2)new properties can only be computed properties. (3)can't replace OOP (4)used for helper function(for beginner). e.g.: extension Int

Back

loop through an array using indices

Front

for index in someArray.indices{}

Back