@@ -3480,182 +3480,227 @@ keep this private. How about number of pairs of cards?
34803480856
3481348100:43:25,136 --> 00:43:28,271
34823482Well, this is one where I don't mind if someone asks
3483+ 嘛,这个我不介意如果其他人知道
34833484
34843485857
3485348600:43:28,340 --> 00:43:30,706
34863487what the number of pairs of cards is but
3488+ 有多少对卡片,但是
34873489
34883490858
3489349100:43:30,775 --> 00:43:36,612
34903492setting the number of pairs of cards would be bad. But
3493+ 设置有多少对卡片是不好的。但
34913494
34923495859
3493349600:43:36,680 --> 00:43:40,816
34943497the thing about this is it's already a get-only property.
3498+ 这个的话,它已经是只读的属性了
34953499
34963500860
3497350100:43:40,885 --> 00:43:43,419
34983502You can't set it anyway, it derives it from other data.
3503+ 你怎么都没法设置它,它是从其他数据衍生出来的
34993504
35003505861
3501350600:43:43,488 --> 00:43:47,022
35023507So we're just gonna make this private, sorry, not private.
3508+ 所以我们就让他是 private 的。不好意思,让他不是 private
35033509
35043510862
3505351100:43:47,091 --> 00:43:49,358
35063512And we're gonna allow people to call this,
3513+ 我们要让别人能够访问这个
35073514
35083515863
3509351600:43:49,427 --> 00:43:51,493
35103517people who are using my ViewController, they can say,
3518+ 使用我这个 ViewController 人可以问
35113519
35123520864
3513352100:43:51,562 --> 00:43:53,496
35143522how many pairs of cards are there? But they can't set it,
3523+ 这里有多少对卡片,但他们不能给它赋值
35153524
35163525865
3517352600:43:53,565 --> 00:43:55,998
35183527cuz this is not settable anyway. Okay, so
3528+ 因为这个本来就没法赋值。好,所以
35193529
35203530866
3521353100:43:56,067 --> 00:43:57,366
35223532that's okay to make that in public.
3533+ 这个是可以公开的
35233534
35243535867
3525353600:43:57,435 --> 00:43:59,902
35263537Same thing flipCount, I think flipCount,
3538+ flipCount 也是类似的,我认为 flipCount
35273539
35283540868
3529354100:43:59,970 --> 00:44:03,272
35303542it's okay for people to get it, but definitely, we don't
3543+ 人们是可以读取它的,但肯定我们不
35313544
35323545869
3533354600:44:03,341 --> 00:44:06,508
35343547want people setting flipCount. That's something we do
3548+ 想让人们赋值给 flipCount。那是我们
35353549
35363550870
3537355100:44:06,577 --> 00:44:08,978
35383552internally when the cards are flip, we implement flipCount.
3553+ 在翻牌的时候内部实现的,我们管理的
35393554
35403555871
3541355600:44:09,046 --> 00:44:12,148
35423557So that's private for the setter, but will allow people
3558+ 所以 setter 是 private 的,但我们允许其他人
35433559
35443560872
3545356100:44:12,216 --> 00:44:14,684
35463562to get the flipCount who are using our thing.
3563+ 在使用的时候获得 flipCount
35473564
35483565873
3549356600:44:14,752 --> 00:44:19,021
35503567Our outlets, almost always we have private outlets.
3568+ 我们这些 @IBOutlet,几乎我们都是让出口保持 private
35513569
35523570874
3553357100:44:19,090 --> 00:44:19,989
35543572Cuz our private outlets,
3573+ 因为我们私有的出口
35553574
35563575875
3557357600:44:20,057 --> 00:44:23,159
35583577these things, and even our actions these are all kind of
3578+ 这些,甚至包括 @IBAction 操作,这些都是
35593579
35603580876
3561358100:44:23,227 --> 00:44:26,295
35623582internal implementation of how we implement our UI.
3583+ 内部对 UI 的实现
35633584
35643585877
3565358600:44:26,364 --> 00:44:29,365
35663587That's what a ViewController does it controls our UI.
3588+ 这就是视图控制器的作用,控制 UI
35673589
35683590878
3569359100:44:29,433 --> 00:44:32,702
35703592Definitely something like update model from UI would be
3593+ 肯定类似于 updateViewFromModel 的方法
35713594
35723595879
3573359600:44:32,771 --> 00:44:35,271
35743597private, that's internal implementation.
3598+ 应该是 private 的,这也是内部实现
35753599
35763600880
3577360100:44:35,339 --> 00:44:38,808
35783602All this emoji business that's all private. Although you
3603+ 这些表情相关的也应该是 private 的,虽然
35793604
35803605881
3581360600:44:38,876 --> 00:44:42,845
35823607could imagine trying to expose some public API eventually
3608+ 你可以计划尝试最终暴露些公有 API
35833609
35843610882
3585361100:44:42,914 --> 00:44:45,848
35863612in this ViewController that let's someone who's using
3613+ 让其他使用 ViewController 的人可以
35873614
35883615883
3589361600:44:45,917 --> 00:44:49,051
35903617our ViewController specify the emojis they want.
3618+ 指定他们想用的表情
35913619
35923620884
3593362100:44:49,120 --> 00:44:53,756
35943622Like, you know, this theme required task that you have,
3623+ 比如某个任务要求用某个主题
35953624
35963625885
3597362600:44:53,824 --> 00:44:57,460
35983627you could imagine that there was a way to specify I want
3628+ 你可以设想我们有一种方法指定我想要
35993629
36003630886
3601363100:44:57,528 --> 00:44:59,995
36023632you mister view controller to play this game,
3633+ ViewController 玩这个游戏
36033634
36043635887
3605363600:45:00,064 --> 00:45:02,998
36063637but I want you to use this emoji as your theme.
3638+ 但是我想要用这套表情作为主题
36073639
36083640888
3609364100:45:03,067 --> 00:45:05,534
36103642See, so you could imagine that something being public.
3643+ 所以设想那种情况下肯定会是有公开的
36113644
36123645889
3613364600:45:05,603 --> 00:45:08,471
36143647I don't think it would be exactly this API,
3648+ 但我不认为会是和这个一样的 API
36153649
36163650890
3617365100:45:08,539 --> 00:45:10,439
36183652it would be some other kind of API,
3653+ 那会是不同的 API
36193654
36203655891
3621365600:45:10,508 --> 00:45:13,942
36223657I'm not sure what they would let you set the emoji to
3658+ 我不确定是什么样的,但它能让你设置使用的表情
36233659
36243660892
3625366100:45:14,011 --> 00:45:16,946
36263662use. We can't really make this public cuz we actually consume
3663+ 这个我们是不能公开的,因为我们实际会消耗
36273664
36283665893
3629366600:45:17,014 --> 00:45:20,883
36303667this. This is a var and we consume it. We have obviously
3668+ 这个数组;这是个变量,而我们会移除里面的内容。肯定
36313669
36323670894
3633367100:45:20,952 --> 00:45:23,119
36343672had to deal with that in your homework I'm sure. And
3673+ 在你们的作业里要解决这个问题。还有
36353674
36363675895
3637367600:45:23,187 --> 00:45:24,954
36383677you know, this dictionary we're building on a fly,
3678+ 你知道的,这个字典我们是及时构建的
36393679
36403680896
3641368100:45:25,022 --> 00:45:26,755
36423682we wouldn't want anyone messing with it, so
3683+ 我们不会想其他人使用它,所以
36433684
36443685897
3645368600:45:26,824 --> 00:45:27,857
36463687I'm gonna keep all this private.
3688+ 我让这些都是 private 的
36473689
36483690898
3649369100:45:27,925 --> 00:45:30,259
36503692This is an example of making it private first and
3693+ 这就是个例子,先让这些都是 private
36513694
36523695899
3653369600:45:30,328 --> 00:45:33,296
36543697then I'm gonna think about what I want to be public.
3698+ 之后我再考虑我要公开哪些
36553699
36563700900
3657370100:45:33,364 --> 00:45:34,997
36583702You see, the design approach there?
3703+ 看到我们用的设计方法了吗?
36593704
36603705901
3661370600:45:35,066 --> 00:45:39,802
0 commit comments