-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path1.Introduction to iOS 10, Xcode 8 and Swift.srt
8124 lines (6499 loc) · 205 KB
/
1.Introduction to iOS 10, Xcode 8 and Swift.srt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1
00:00:00,401 --> 00:00:04,402
[MUSIC]
2
00:00:04,471 --> 00:00:07,239
Stanford University.
斯坦福大学
3
00:00:07,308 --> 00:00:11,877
Okay, well, welcome to CS193P, Stanford CS193P.
欢迎参加 2017 年冬季学期斯坦福 CS193P 课程
4
00:00:13,481 --> 00:00:17,515
This is Developing Applications for iOS, winter
iOS 应用程序开发
5
00:00:17,584 --> 00:00:21,553
of 2017. Today we're going to talk a little bit about what
我们今天先会讲讲本课的主要内容
6
00:00:21,622 --> 00:00:23,955
this class is about, and the prerequisites you need.
和上这门课之前你所需要具备的能力
7
00:00:24,024 --> 00:00:28,427
Then I'm, really fast, gonna go over iOS and what's in it.
之后我会很快地过一遍什么是 iOS,由什么构成
8
00:00:28,496 --> 00:00:32,330
And then, I'm gonna dive into a big, long demo.
最后我会带大家做一个很完整的示例程序
9
00:00:32,399 --> 00:00:34,833
And this demo is gonna really quickly let you see what it's
给你们展示一下开发 iOS 程序是什么感觉
10
00:00:34,902 --> 00:00:37,402
like to develop an application for iOS, so you can decide,
你们可以再决定
11
00:00:37,471 --> 00:00:40,738
is this for me, or not? So, what are you gonna learn?
究竟适不适合你。这门课主要我们主要会讲
12
00:00:40,807 --> 00:00:43,441
Well you're gonna learn to build cool apps, all right,
如何开发很酷的 app
13
00:00:43,510 --> 00:00:46,778
that's, that's what we're here for. Why are these apps in iOS
当然了,你们来这里就是为了这个。可是为什么 iOS 上的程序这么 cool 呢?
14
00:00:46,847 --> 00:00:48,947
cool? Well for a number of reasons, okay?
这其中有几个原因
15
00:00:49,016 --> 00:00:50,982
One is they're in your back pocket,
首先是你可以随时
16
00:00:51,051 --> 00:00:54,085
you can pull them out and show your friends on your phone,
把手机拿出来展示给他们看
17
00:00:54,154 --> 00:00:57,288
a lot of them are networked so there're kind of social
许多 app 可以联网,而这些社交类的程序
18
00:00:57,357 --> 00:01:00,525
apps and a lot of that can be a lot of fun.
通常都能给我们带来欢乐
19
00:01:00,594 --> 00:01:03,595
Also if you decide to turn your app into a product it's
如果你决定发布你写的程序
20
00:01:03,663 --> 00:01:06,030
really easy to get it out to customers via the App Store.
你能很轻松地通过 App Store 展示给顾客
21
00:01:06,099 --> 00:01:07,900
You don't have to wrap it in a box and
你不再需要把程序
22
00:01:07,968 --> 00:01:10,468
put it on a shelf somewhere anymore. You can get it out
用盒子包装好后放到货架上了
23
00:01:10,537 --> 00:01:12,971
there real quick. And also you're going to see,
不仅上架的过程快,你马上会见识到
24
00:01:13,040 --> 00:01:16,608
today even, it's really easy to build pretty complex
就算是很复杂的 app
25
00:01:16,677 --> 00:01:20,012
app pretty quickly. So you get a lot of instant gratification
我们也能很轻松地写出来,让你马上就觉得
26
00:01:20,080 --> 00:01:22,548
from building iOS apps. For those of you in
开发 iOS 程序很有成就感
27
00:01:22,616 --> 00:01:25,751
computer science there's also this huge benefit, you're
对于那些选修计算机科学的同学们
28
00:01:25,819 --> 00:01:28,820
gonna get to see a real life object-oriented programming
你们能实际观察到面向对象系统的应用
29
00:01:28,889 --> 00:01:31,623
system. And not just object-oriented programming,
当然我们不只会讲面向对象编程
30
00:01:31,691 --> 00:01:34,192
but we're going to use databases in this class, and
我们还会使用数据库
31
00:01:34,261 --> 00:01:37,362
graphics, and multimedia, multi-threading, animation,
图形用户界面,多媒体,多线程,动画
32
00:01:37,430 --> 00:01:39,364
networking, all these things. And
网络,等等
33
00:01:39,433 --> 00:01:40,932
you're going to see it in a real world environment.
而且我们会在真实的情景下学习
34
00:01:41,001 --> 00:01:43,635
So you take a lot of classes on these subjects
你们多半已经上了不少关于编程或是计算机的课了
35
00:01:43,704 --> 00:01:46,137
and sometimes you get maybe a little disconnected from
相信有时候你会觉得那些课程
36
00:01:46,206 --> 00:01:47,472
what's this like in the real world, well,
都有些脱离实际
37
00:01:47,541 --> 00:01:52,211
you're gonna get to see it all in action here. Prerequisites,
我们这门课就是让你见识下这些抽象概念的实际运用
38
00:01:52,279 --> 00:01:55,414
just boiling it down really easily. The prerequisite for
上这门课之前你所需要具备的能力
39
00:01:55,483 --> 00:01:57,282
the class is object-oriented programming.
肯定少不了面向对象
40
00:01:57,350 --> 00:01:59,151
You have to know object-oriented programming,
你必须要了解面向对象编程
41
00:01:59,219 --> 00:02:01,586
I'm not gonna teach that in the class, I completely and
我绝不会在课上讲关于面向对象的知识
42
00:02:01,655 --> 00:02:04,289
utterly assume it. And not only do you have to know it,
你还不能只是听说过面向对象
43
00:02:04,358 --> 00:02:06,057
you have to have some experience doing it.
你还应该实际运用过
44
00:02:06,126 --> 00:02:09,260
So that's why here at Stanford CS106 A and
换言之,你需要上过斯坦福 CS106 A 或 B
45
00:02:09,329 --> 00:02:12,131
B are a hard prerequisite. You have to have taken those two,
这是硬性条件,你必须要上过至少其中一门
46
00:02:12,199 --> 00:02:14,733
those are object-oriented programming classes. And
你将会在那些课程中学到面向对象编程的相关知识
47
00:02:14,801 --> 00:02:16,535
then I just want to make sure you have some programming
其次是你要有些编程的经验
48
00:02:16,603 --> 00:02:19,338
experience, so either you've done something outside
可以是你课外活动
49
00:02:19,406 --> 00:02:22,608
of school, or you've taken CS107 or CS108 or CS110.
也可以是上过 CS107、CS108、CS110 其中的一个
50
00:02:22,676 --> 00:02:25,310
CS108 is a particularly great prerequisite,
如果你不满足这些条件,CS108 是个不错的选择
51
00:02:25,378 --> 00:02:27,646
that's object-oriented programming.
那门课会讲面向对象编程
52
00:02:27,715 --> 00:02:29,614
So if you have a chance to take CS108 and
所以如果你需要但还没有去上一门这样的课
53
00:02:29,683 --> 00:02:32,216
you haven't taken it yet, yeah, maybe taken it, and
你最好现在换成 CS108
54
00:02:32,285 --> 00:02:35,520
then take this class the next time it's offered, all right?
等下次提供 CS193P 的时候再来上也不迟
55
00:02:35,588 --> 00:02:41,025
So let's dive through what's in iOS really quickly here.
我们简单讲讲 iOS 系统的构成
56
00:02:41,094 --> 00:02:43,595
I've divided it here into four layers.
我将 iOS 分为了 4 层
57
00:02:43,664 --> 00:02:46,531
These layers are roughly close to the hardware.
越下面的越接近硬件
58
00:02:46,600 --> 00:02:49,968
And then up close to the user. So that bottom layer close to
越上面的越接近用户。我们看到那个
59
00:02:50,037 --> 00:02:53,238
the hardware, that's actually a UNIX operating system, okay?
最接近硬件的那层,那其实是 UNIX 操作系统
60
00:02:53,306 --> 00:02:56,941
Just like macOS, iOS is a UNIX operating system at
就像 macOS 一样,iOS 也是基于 UNIX 操作系统
61
00:02:57,010 --> 00:02:59,444
the bottom. None of these APIs are object oriented or
这些 API(应用程序接口)都不是面向对象的
62
00:02:59,513 --> 00:03:01,280
anything, they're basically C, okay? For
因为它们基本上都是用 C 语言写出来的
63
00:03:01,348 --> 00:03:05,551
the UNIX pretty much written in C, these API's are in C.
因为 UNIX 是用 C 语言写的,API 自然也是 C 风格的
64
00:03:05,619 --> 00:03:10,122
We're gonna do no work at that level in this class, okay?
我们不会在这门课中涉及到这个层次的编程
65
00:03:10,190 --> 00:03:10,989
This is an object-oriented programming only class,
我们只会涉及到有关于面向对象编程的内容
66
00:03:11,057 --> 00:03:11,690
so we're not gonna be doing anything there.
不会和 C 打交道
67
00:03:11,758 --> 00:03:14,659
So there's another layer right on top of that called core
在那一层之上是 Core Serviecs 层
68
00:03:14,728 --> 00:03:17,662
services. Sometimes people refer to this as foundation,
这一层主要是 Foundation
69
00:03:17,731 --> 00:03:21,333
but there's other things in this lever, layer,
但其实在这一层中除了 Foundation 以外
70
00:03:21,401 --> 00:03:24,836
besides foundation. And this is an object oriented layer
还有其它的功能。这一层实际上是
71
00:03:24,905 --> 00:03:27,539
on top of those things that were lower down. Okay, so
我们之前看到那一层经过了面向对象的封装
72
00:03:27,607 --> 00:03:30,875
now you can do networking, file system, things like that,
实现网络传输,访问文件系统的 API
73
00:03:30,944 --> 00:03:34,512
using object oriented API. But this is still non UI layer,
都是面向对象的。虽然这一层依旧不会涉及到用户界面
74
00:03:34,581 --> 00:03:38,283
right? It's still kinda closer to the hardware. So I'll
这层离硬件还算近的,
75
00:03:38,351 --> 00:03:40,619
definitely be teaching you a lot of stuff at this layer,
所以我们会在这上面多下点功夫
76
00:03:40,688 --> 00:03:43,721
'cause you just need it to do the things you're gonna do.
因为这些是必不可少的
77
00:03:43,790 --> 00:03:47,059
Now, there's another layer here, the media layer here I
下一层是媒体处理层
78
00:03:47,127 --> 00:03:51,262
call it. This is a huge layer, which has 3D graphics, and
这一层包含 3D 绘制
79
00:03:51,331 --> 00:03:55,533
audio playback and recording, image processing, video,
音频播放,录音,图像处理,视频等相关的功能。
80
00:03:55,602 --> 00:03:58,470
all that stuff. Unfortunately I'm not gonna have a lot of
可惜我们并没有什么时间学习这些
81
00:03:58,538 --> 00:04:01,006
time to spend here, even though it's a huge part of
即使这是 iOS 设备日常使用所需要的功能
82
00:04:01,074 --> 00:04:05,977
what an iOS device does. iOS devices all pretty much have
所有的 iOS 设备都能被当作一个 iPods 使用
83
00:04:06,046 --> 00:04:09,681
iPods in them, video iPods if you wanna think about it.
或者你也可以把它们叫做有显示屏的“iPods”
84
00:04:09,749 --> 00:04:12,584
And so there's a lot here. Unfortunately I can't cover it
当然不止这些功能,不过我依然不能细讲这些
85
00:04:12,653 --> 00:04:15,454
all. Because I'm gonna spend most of my time up here,
因为我们大部分时间都会花在这儿
86
00:04:15,523 --> 00:04:17,189
which is the Cocoa Touch layer.
Cocoa Touch 层
87
00:04:17,257 --> 00:04:20,058
This is where buttons and text fields and things are, but
这一层包含了按钮,文本字段等控件
88
00:04:20,127 --> 00:04:22,727
also much more powerful objects like maps.
甚至还包括那些功能强大的类,比如地图
89
00:04:22,796 --> 00:04:26,131
There's an object in Cocoa Touch which is a map object,
Cocoa Touch 层中定义了一个地图的类
90
00:04:26,200 --> 00:04:29,368
it's pretty much the entire Maps application on
那基本包含了 iOS 上地图程序所有的功能
91
00:04:29,436 --> 00:04:32,704
an iOS device, that you can drop right into a rectangle
你只需要把它放到你程序的界面上就行了
92
00:04:32,773 --> 00:04:35,573
in your app. With almost no work.
除此之外你基本什么都不需要做
93
00:04:35,642 --> 00:04:38,676
So, very powerful object to this layer. This is where
所以这一层的类都很好用
94
00:04:38,745 --> 00:04:40,779
we're gonna spend the vast majority of our time,
我们大部分时间也会学习
95
00:04:40,847 --> 00:04:43,315
building user interface apps at this layer.
如何在这个层面构建用户界面
96
00:04:44,618 --> 00:04:47,886
That's a rough overview. Trying to explain all
大概 iOS 系统的构成就是这样
97
00:04:47,955 --> 00:04:50,655
of iOS in two minutes is pretty much impossible, but
这么几分钟就完整地介绍 iOS 操作系统基本是不可能的
98
00:04:50,724 --> 00:04:53,825
that's kind of what we're doing in this class. We're
但你应该大概知道这门课程大概会包括哪些内容了
99
00:04:53,894 --> 00:04:57,029
gonna use all these components to get our work done.
iOS 开发是由以下几个部分构成的
100
00:04:57,098 --> 00:04:59,431
Top level there, Xcode 8, is gonna be...
首先是 Xcode 8
101
00:04:59,500 --> 00:05:01,766
everything we do is gonna be in Xcode 8.
我们所有事情都是在 Xcode 8 里完成的
102
00:05:01,835 --> 00:05:04,802
The debugger, the editor, everything, building,
调试器,编辑器,编译,等等
103
00:05:04,871 --> 00:05:08,173
it's all in Xcode 8. There's a little app, Instruments,
Xcode 8 都能搞定。我们还会用到 Instruments
104
00:05:08,242 --> 00:05:10,742
that goes along with it, for performance and stuff, but
Xcode 附带的小程序,能用来检测程序的性能
105
00:05:10,811 --> 00:05:13,845
pretty much it's all Xcode 8. Two, I'm gonna teach you
不过我们还是使用 Xcode 8 的时候比较多
106
00:05:13,914 --> 00:05:17,349
a new programming language. So if you're computer science
然后我们将学一门新的编程语言
107
00:05:17,418 --> 00:05:20,052
people, you know that learning different programming
学计算机科学的同学们应该知道
108
00:05:20,120 --> 00:05:22,354
languages, really valuable skill.
多学会一门语言是很有用的
109
00:05:22,423 --> 00:05:24,056
Not because you're necessarily gonna use all of them,
并不是说平常我们要把学过的语言都用上
110
00:05:24,124 --> 00:05:27,158
some you might or might not use. But just the process of
这需要根据情况取舍
111
00:05:27,227 --> 00:05:30,896
seeing how language designers pick and choose their syntax
不过光是研究设计语言这群人
112
00:05:30,965 --> 00:05:33,732
and, and the feature set, is really valuable.
决定的语法和功能,你都应该得到些收获
113
00:05:33,800 --> 00:05:36,702
So you'll get that I would think. It's a great language.
Swift 是世界上最好的语言
114
00:05:36,770 --> 00:05:38,770
It was just invented in the last two or three years, so
它在两三年前(2014年)才被发明出来
115
00:05:38,839 --> 00:05:40,806
it kind of incorporates the best of a lot of different
所以它集成了各种语言的精华
116
00:05:40,874 --> 00:05:44,475
languages. So I'm gonna kind of blitzkrieg teach that to
我将会用前几周的时间用填鸭式教会你们
117
00:05:44,544 --> 00:05:48,547
you in the first couple weeks. Frameworks: That's essentially
框架是必不可少的
118
00:05:48,615 --> 00:05:51,450
things like the Cocoa Touch UIKit framework.
就比如 Cocoa Touch 的 UIKit 框架
119
00:05:51,519 --> 00:05:52,884
It's where all the buttons and stuff are.
就是它包含了我们要用的按钮等控件
120
00:05:52,953 --> 00:05:54,452
Foundation is that, kind of,
Foundation 框架,正如我们之前说的
121
00:05:54,521 --> 00:05:56,021
mostly that Core Services layer.
主要是 Core Services 层的
122
00:05:56,089 --> 00:05:58,356
But there's a lot of other ones like Core Data framework,
当然还有不少其它的框架,比如 Core Data 框架
123
00:05:58,425 --> 00:05:59,625
object-oriented database,
面向对象的数据库
124
00:05:59,694 --> 00:06:01,293
we'll be doing that in assignment five.
我们将会在第五个作业中用到
125
00:06:01,361 --> 00:06:05,730
Also I talked about that map thing, that's in a framework
之前说的很牛的地图,那是 MapKit 框架里的
126
00:06:05,799 --> 00:06:08,534
called MapKit. And there's also things in Core Motion,
你能通过 Core Motion 框架读取
127
00:06:08,602 --> 00:06:11,470
like the accelerometer and the gyro in the device.
设备的加速度计和陀螺仪的数据
128
00:06:11,538 --> 00:06:13,071
All those things, I'm gonna be teaching you many,
一路上我们将学到
129
00:06:13,140 --> 00:06:15,540
many of these frameworks as we go on. And
越来越多的框架
130
00:06:15,609 --> 00:06:17,676
last, but definitely not least, and very,
最后, 非常重要的
131
00:06:17,745 --> 00:06:20,145
very important, is the design strategy for
是关于如何构建程序的设计模式
132
00:06:20,214 --> 00:06:23,315
how to build apps, it's called MVC, model-view-controller.
MVC, 即 Model(模型)-View(视图)-Controller(控制器)
133
00:06:23,384 --> 00:06:25,484
How many people already know MVC, have,
在场的同学有多少是听说过 MVC 的?
134
00:06:25,552 --> 00:06:27,152
have learned in a different class?
有多少学过的?
135
00:06:27,220 --> 00:06:30,288
See, so maybe half of you. I will spend the first part of
大概有一半吧。那我星期三
136
00:06:30,357 --> 00:06:33,659
Wednesday's lecture telling you about MVC and what it is.
上课时再讲讲 MVC 的概念
137
00:06:33,727 --> 00:06:38,696
We 100.0% have to use MVC when we develop apps for iOS.
我们在开发 iOS 程序的时候肯定会用到 MVC
138
00:06:38,765 --> 00:06:41,300
There's really no other way to do it, if you do it any other
可以说这是你无可厚非的选择
139
00:06:41,368 --> 00:06:43,902
way, you're swimming so up stream against the current of
如果你要另辟蹊径的话,那也只是逆水行舟
140
00:06:43,970 --> 00:06:47,239
iOS, it's... You'll end up with a mess of an application,
你最终会发现你的程序乱成一团糟
141
00:06:47,308 --> 00:06:50,275
okay, so we'll be going over that as well. This demo
所以我们会讲讲 MVC
142
00:06:50,343 --> 00:06:53,045
that I'm gonna do, we're gonna build a calculator.
接下了我们要写一个计算器程序
143
00:06:53,113 --> 00:06:56,181
A calculator's great because it's got a fairly simple UI,
因为它的界面很简单
144
00:06:56,250 --> 00:06:58,617
but it's got a little bit of guts on the inside,
其实计算结果的部分
145
00:06:58,686 --> 00:07:00,319
the actual calculating part. So
又有些难度
146
00:07:00,387 --> 00:07:03,355
it's just complicated enough to start showing you MVC and
用它来示范 MVC 刚刚好
147
00:07:03,424 --> 00:07:06,557
a lot of language features and things like that. But not so
能用到许多 Swift 语言的特性
148
00:07:06,626 --> 00:07:09,928
complicated that I can't do an entire calculator, basically,
但又不会难到
149
00:07:09,997 --> 00:07:13,131
in two lectures, okay, start to finish. All these topics up
我没法在两堂课内讲完。
150
00:07:13,200 --> 00:07:14,933
here, you don't have to look at them now.
你不需要太在意现在你看到的这些
151
00:07:15,002 --> 00:07:18,203
This is the slide to go look at after my lecture today and
在我讲完之后你自己再来看
152
00:07:18,272 --> 00:07:20,239
say, hmm did I learn that, yeah,
问问自己我是否学会了
153
00:07:20,307 --> 00:07:22,173
I think I got that. So
我是否掌握了
154
00:07:22,242 --> 00:07:25,177
it's kind of a summary of what I'm gonna do. Since I'm not
这就是这个课程大纲的用法
155
00:07:25,246 --> 00:07:27,045
gonna get back to the slides from the end of my demo,
既然我演示完之后多半下课了
156
00:07:27,114 --> 00:07:28,614
it's just gonna be the end of the lecture.
不会再回到这一页
157
00:07:28,682 --> 00:07:30,615
I'll tell you a little bit what's coming up.
我现在就先讲讲之后的课程安排
158
00:07:30,684 --> 00:07:33,251
On Wednesday, I'll be continuing this demo, but
星期三我会继续编这个计算器
159
00:07:33,320 --> 00:07:35,654
not until after I give you this talk about MVC,
但我肯定要先讲 MVC
160
00:07:35,723 --> 00:07:38,690
because what we're gonna do in the calculator is apply MVC
因为下节课我们就要
161
00:07:38,758 --> 00:07:41,760
to it, on Wednesday. And your first
在计算器中运用 MVC
162
00:07:41,829 --> 00:07:44,696
programming assignment will go out on Wednesday, which is
星期三我们还会放出第一个编程作业
163
00:07:44,765 --> 00:07:47,198
pretty much to replicate what I'm doing today and
你们只需要依葫芦画瓢
164
00:07:47,267 --> 00:07:51,069
on Wednesday, okay? And I'll give you a video of the demo,
照着我今天和星期三的视频做一遍
165
00:07:51,138 --> 00:07:54,840
so you'll see it, and you'll be able to watch it. And
没错,我会把视频发给你们
166
00:07:54,908 --> 00:07:57,709
then on Friday, we have an optional section.
星期五的课是选修课,不会放到 iTunes U 上
167
00:07:57,778 --> 00:07:59,211
So the Friday sections in this course,
所以星期五的课
168
00:07:59,280 --> 00:08:01,046
you don't have to go to if you don't want to.
同学们不感兴趣可以不来上
169
00:08:01,115 --> 00:08:03,248
But a lot of times, they're very valuable
但其实这些课程都一般都很有用
170
00:08:03,317 --> 00:08:07,085
feature. So if you have not used the debugger in Xcode 8
所以如果你没有用过 Xcode 8 的调试器
171
00:08:07,154 --> 00:08:10,022
you really might wanna go to Friday's lecture.
我推荐你来听听
172
00:08:10,090 --> 00:08:12,790
The location and time of it will be posted on the class
上课的时间和地点看我之后发的公告
173
00:08:12,859 --> 00:08:15,994
forums hopefully tomorrow. I've asked for the room and
我还在申请上课用的教室
174
00:08:16,062 --> 00:08:18,196
haven't quite got it yet so hopefully tomorrow. And
希望明天能搞定,然后通知你们
175
00:08:18,264 --> 00:08:20,565
then don't forget next Monday is a holiday so we're not
下周一放假,不上课
176
00:08:20,634 --> 00:08:23,067
meeting on Monday. Our next class after this Wednesday
所以再下一次上课是星期三
177
00:08:23,136 --> 00:08:28,540
will be next Wednesday. So let's hop into the demo...
好,我们开始 demo 吧
178
00:08:28,608 --> 00:08:31,743
I said we were gonna build a calculator, let me actually
既然我们要编一个计算器
179
00:08:31,811 --> 00:08:36,315
show you a calculator. This is the macOS calculator and
那我们先来看 macOS 上的计算器
180
00:08:36,383 --> 00:08:39,050
our calculator is gonna look very similar to this, right?
我们的计算器基本会照着这个来做
181
00:08:39,119 --> 00:08:42,520
It has to display along the top, it has the keypad for
最上面是显示,下面是按键
182
00:08:42,589 --> 00:08:46,058
typing numbers in and it's got these operation buttons. And
包括输入数字和执行运算的按钮
183
00:08:46,126 --> 00:08:49,294
then you can just multiply, times eight, you hit equals,
比如我们现在按 乘,8,等于
184
00:08:49,362 --> 00:08:50,395
it does the operation,
它就会计算出来
185
00:08:50,464 --> 00:08:52,463
that's pretty much what our calculator is gonna do.
我们的计算器就是要实现这样的功能
186
00:08:52,532 --> 00:08:55,100
It's not gonna look exactly like this. It's gonna have
我们 app 的界面不会和这个完全一样
187
00:08:55,169 --> 00:08:58,370
a look that's a little more appropriate for a iOS device,
因为我们会在保持界面基本元素的基础上
188
00:08:58,439 --> 00:09:03,041
but it's generally this. And I promised that Xcode would be
为适应 iOS 设备作出些微调
189
00:09:03,110 --> 00:09:05,210
your one-stop shop for doing all development, so
Xcode 无所不能
190
00:09:05,278 --> 00:09:08,847
we're gonna spend our entire time here working in Xcode.
因此我们开发会全程使用 Xcode
191
00:09:08,916 --> 00:09:12,117
Now Xcode is an app that you just go to the Mac App Store,
你可以从 Mac App Store 上免费下载
192
00:09:12,186 --> 00:09:13,952
and you download it. It's free.
请勿从百度云等第三方渠道下载
193
00:09:14,020 --> 00:09:16,688
When you first launch it, it's gonna put up this splash
当你第一次打开它的时候,你可以看到这个
194
00:09:16,757 --> 00:09:18,724
screen like you see right here.
这个欢迎界面
195
00:09:18,792 --> 00:09:21,927
And all of your projects are going to start accumulating
Xcode 会记住你的各个项目
196
00:09:21,995 --> 00:09:26,265
here over on this right side where this gray area is. And
并展示在现在这片灰色的地方
197
00:09:26,333 --> 00:09:29,634
you can basically do three other things here. You can use
这里有三个选项
198
00:09:29,703 --> 00:09:32,004
a playground, which I'll show the playgrounds on Wednesday,
你可以新建一个 playgroud,这我星期三会讲
199
00:09:32,072 --> 00:09:35,440
it's kind of a little play area for iOS programming. You
你可以在 playground 中简单试试自己的代码
200
00:09:35,509 --> 00:09:38,911
can check a existing project out of a source control
你可以添加代码管理源的项目
201