MYF

CS193p-L2 MVC

课程名称:Developing iOS 11 Apps with Swift
课程链接 https://itunes.apple.com/podcast/id1315130780

  • Model = What your application is (but not how it is displayed)
  • Controller = How your Model is presented to the user(UI logic)
  • View = Your Controller’s minions

Class和Struct的区别

Struct无继承
class有继承

struct是value type
class是reference type

for

1
for identifier in 0..< numberOfPairOfCards{    // ..}

等价于

1
for( int identifier = 0; identifier < numberOfPairOfCards;  identifier++){ ... }

lazy

等到有可用的情况下再init

1
lazy var game: Concentration = Concentration(numberOfPairsOfCards: (cardButtons.count + 1)/2)

optional

1
2
3
4
5
6
7
if emoji[card.identifier] != nil {
return emoji[card.identifier]!
}

//等价于

return emoji[card.identifier] ?? "?"