Skip to content

Commit 6e0bd2b

Browse files
committed
3_856-900
1 parent b81dd16 commit 6e0bd2b

File tree

1 file changed

+45
-0
lines changed

1 file changed

+45
-0
lines changed

subtitles/3. Swift Programming Language.srt

100644100755
Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3480,182 +3480,227 @@ keep this private. How about number of pairs of cards?
34803480
856
34813481
00:43:25,136 --> 00:43:28,271
34823482
Well, this is one where I don't mind if someone asks
3483+
嘛,这个我不介意如果其他人知道
34833484

34843485
857
34853486
00:43:28,340 --> 00:43:30,706
34863487
what the number of pairs of cards is but
3488+
有多少对卡片,但是
34873489

34883490
858
34893491
00:43:30,775 --> 00:43:36,612
34903492
setting the number of pairs of cards would be bad. But
3493+
设置有多少对卡片是不好的。但
34913494

34923495
859
34933496
00:43:36,680 --> 00:43:40,816
34943497
the thing about this is it's already a get-only property.
3498+
这个的话,它已经是只读的属性了
34953499

34963500
860
34973501
00:43:40,885 --> 00:43:43,419
34983502
You can't set it anyway, it derives it from other data.
3503+
你怎么都没法设置它,它是从其他数据衍生出来的
34993504

35003505
861
35013506
00:43:43,488 --> 00:43:47,022
35023507
So we're just gonna make this private, sorry, not private.
3508+
所以我们就让他是 private 的。不好意思,让他不是 private
35033509

35043510
862
35053511
00:43:47,091 --> 00:43:49,358
35063512
And we're gonna allow people to call this,
3513+
我们要让别人能够访问这个
35073514

35083515
863
35093516
00:43:49,427 --> 00:43:51,493
35103517
people who are using my ViewController, they can say,
3518+
使用我这个 ViewController 人可以问
35113519

35123520
864
35133521
00:43:51,562 --> 00:43:53,496
35143522
how many pairs of cards are there? But they can't set it,
3523+
这里有多少对卡片,但他们不能给它赋值
35153524

35163525
865
35173526
00:43:53,565 --> 00:43:55,998
35183527
cuz this is not settable anyway. Okay, so
3528+
因为这个本来就没法赋值。好,所以
35193529

35203530
866
35213531
00:43:56,067 --> 00:43:57,366
35223532
that's okay to make that in public.
3533+
这个是可以公开的
35233534

35243535
867
35253536
00:43:57,435 --> 00:43:59,902
35263537
Same thing flipCount, I think flipCount,
3538+
flipCount 也是类似的,我认为 flipCount
35273539

35283540
868
35293541
00:43:59,970 --> 00:44:03,272
35303542
it's okay for people to get it, but definitely, we don't
3543+
人们是可以读取它的,但肯定我们不
35313544

35323545
869
35333546
00:44:03,341 --> 00:44:06,508
35343547
want people setting flipCount. That's something we do
3548+
想让人们赋值给 flipCount。那是我们
35353549

35363550
870
35373551
00:44:06,577 --> 00:44:08,978
35383552
internally when the cards are flip, we implement flipCount.
3553+
在翻牌的时候内部实现的,我们管理的
35393554

35403555
871
35413556
00:44:09,046 --> 00:44:12,148
35423557
So that's private for the setter, but will allow people
3558+
所以 setter 是 private 的,但我们允许其他人
35433559

35443560
872
35453561
00:44:12,216 --> 00:44:14,684
35463562
to get the flipCount who are using our thing.
3563+
在使用的时候获得 flipCount
35473564

35483565
873
35493566
00:44:14,752 --> 00:44:19,021
35503567
Our outlets, almost always we have private outlets.
3568+
我们这些 @IBOutlet,几乎我们都是让出口保持 private
35513569

35523570
874
35533571
00:44:19,090 --> 00:44:19,989
35543572
Cuz our private outlets,
3573+
因为我们私有的出口
35553574

35563575
875
35573576
00:44:20,057 --> 00:44:23,159
35583577
these things, and even our actions these are all kind of
3578+
这些,甚至包括 @IBAction 操作,这些都是
35593579

35603580
876
35613581
00:44:23,227 --> 00:44:26,295
35623582
internal implementation of how we implement our UI.
3583+
内部对 UI 的实现
35633584

35643585
877
35653586
00:44:26,364 --> 00:44:29,365
35663587
That's what a ViewController does it controls our UI.
3588+
这就是视图控制器的作用,控制 UI
35673589

35683590
878
35693591
00:44:29,433 --> 00:44:32,702
35703592
Definitely something like update model from UI would be
3593+
肯定类似于 updateViewFromModel 的方法
35713594

35723595
879
35733596
00:44:32,771 --> 00:44:35,271
35743597
private, that's internal implementation.
3598+
应该是 private 的,这也是内部实现
35753599

35763600
880
35773601
00:44:35,339 --> 00:44:38,808
35783602
All this emoji business that's all private. Although you
3603+
这些表情相关的也应该是 private 的,虽然
35793604

35803605
881
35813606
00:44:38,876 --> 00:44:42,845
35823607
could imagine trying to expose some public API eventually
3608+
你可以计划尝试最终暴露些公有 API
35833609

35843610
882
35853611
00:44:42,914 --> 00:44:45,848
35863612
in this ViewController that let's someone who's using
3613+
让其他使用 ViewController 的人可以
35873614

35883615
883
35893616
00:44:45,917 --> 00:44:49,051
35903617
our ViewController specify the emojis they want.
3618+
指定他们想用的表情
35913619

35923620
884
35933621
00:44:49,120 --> 00:44:53,756
35943622
Like, you know, this theme required task that you have,
3623+
比如某个任务要求用某个主题
35953624

35963625
885
35973626
00:44:53,824 --> 00:44:57,460
35983627
you could imagine that there was a way to specify I want
3628+
你可以设想我们有一种方法指定我想要
35993629

36003630
886
36013631
00:44:57,528 --> 00:44:59,995
36023632
you mister view controller to play this game,
3633+
ViewController 玩这个游戏
36033634

36043635
887
36053636
00:45:00,064 --> 00:45:02,998
36063637
but I want you to use this emoji as your theme.
3638+
但是我想要用这套表情作为主题
36073639

36083640
888
36093641
00:45:03,067 --> 00:45:05,534
36103642
See, so you could imagine that something being public.
3643+
所以设想那种情况下肯定会是有公开的
36113644

36123645
889
36133646
00:45:05,603 --> 00:45:08,471
36143647
I don't think it would be exactly this API,
3648+
但我不认为会是和这个一样的 API
36153649

36163650
890
36173651
00:45:08,539 --> 00:45:10,439
36183652
it would be some other kind of API,
3653+
那会是不同的 API
36193654

36203655
891
36213656
00:45:10,508 --> 00:45:13,942
36223657
I'm not sure what they would let you set the emoji to
3658+
我不确定是什么样的,但它能让你设置使用的表情
36233659

36243660
892
36253661
00:45:14,011 --> 00:45:16,946
36263662
use. We can't really make this public cuz we actually consume
3663+
这个我们是不能公开的,因为我们实际会消耗
36273664

36283665
893
36293666
00:45:17,014 --> 00:45:20,883
36303667
this. This is a var and we consume it. We have obviously
3668+
这个数组;这是个变量,而我们会移除里面的内容。肯定
36313669

36323670
894
36333671
00:45:20,952 --> 00:45:23,119
36343672
had to deal with that in your homework I'm sure. And
3673+
在你们的作业里要解决这个问题。还有
36353674

36363675
895
36373676
00:45:23,187 --> 00:45:24,954
36383677
you know, this dictionary we're building on a fly,
3678+
你知道的,这个字典我们是及时构建的
36393679

36403680
896
36413681
00:45:25,022 --> 00:45:26,755
36423682
we wouldn't want anyone messing with it, so
3683+
我们不会想其他人使用它,所以
36433684

36443685
897
36453686
00:45:26,824 --> 00:45:27,857
36463687
I'm gonna keep all this private.
3688+
我让这些都是 private 的
36473689

36483690
898
36493691
00:45:27,925 --> 00:45:30,259
36503692
This is an example of making it private first and
3693+
这就是个例子,先让这些都是 private
36513694

36523695
899
36533696
00:45:30,328 --> 00:45:33,296
36543697
then I'm gonna think about what I want to be public.
3698+
之后我再考虑我要公开哪些
36553699

36563700
900
36573701
00:45:33,364 --> 00:45:34,997
36583702
You see, the design approach there?
3703+
看到我们用的设计方法了吗?
36593704

36603705
901
36613706
00:45:35,066 --> 00:45:39,802

0 commit comments

Comments
 (0)