-
Notifications
You must be signed in to change notification settings - Fork 149
/
1. Introduction to iOS 11, Xcode 9 and Swift 4.srt
8098 lines (6479 loc) · 211 KB
/
1. Introduction to iOS 11, Xcode 9 and Swift 4.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,202
本字幕由志愿者义务贡献,采用许可协议
知识共享 署名-非商业性使用-相同方式共享 3.0 美国
2
00:00:04,271 --> 00:00:09,341
Stanford University. >> Okay, well welcome then,
斯坦福大学 >> 欢迎参加
3
00:00:09,409 --> 00:00:13,545
to Stanford CS193P. This is Developing Applications for
斯坦福 CS193P,iOS 应用程序开发
4
00:00:13,614 --> 00:00:15,914
iOS. Hopefully you're in the right place.
希望你们走对了教室
5
00:00:15,983 --> 00:00:20,319
This is fall quarter of 2017. And I'm gonna breeze through
现在是 2017 年秋季学期。我先简单
6
00:00:20,387 --> 00:00:22,754
a few slides here. And then I'm gonna sit down and
讲几页幻灯片,然后坐下来
7
00:00:22,823 --> 00:00:25,256
do a nice involved demo just to show you what it's like
给你们写个程序演示一下
8
00:00:25,325 --> 00:00:27,960
developing apps for iOS. That's the best way to learn,
开发 iOS 程序是什么样的。这是最好的学习方法
9
00:00:28,029 --> 00:00:30,094
it's for me to show you how to do it. So
让我来给你展示怎么做
10
00:00:30,163 --> 00:00:32,231
this will be what I'm gonna talk about briefly first.
现在我先简单讲讲
11
00:00:32,299 --> 00:00:33,465
So what are you gonna learn in this course?
你在这节课会学到什么?
12
00:00:33,534 --> 00:00:35,901
Of course you're gonna learn how to build cool apps.
当然你会学习如何编写很酷的程序
13
00:00:35,970 --> 00:00:39,304
iOS apps are cool. Why are they cool?
iOS 程序都很酷,为什么呢?
14
00:00:39,372 --> 00:00:42,540
Well, they're cool because they live in your pocket, you
因为他们“活”在你的口袋里(的手机上)
15
00:00:42,609 --> 00:00:45,777
can show them to your friends right there, also incredibly
你随时可以展示给你的朋友们看
16
00:00:45,845 --> 00:00:48,813
easy to sell and market your apps online because you have
同时还能很轻松地在在线商店销售,因为
17
00:00:48,882 --> 00:00:52,017
the App Store. And there's a very vibrant community that's
有 App Store。那可是个很活跃的大平台
18
00:00:52,086 --> 00:00:54,953
because Apple is always doing cool new things like virtual
因为苹果公司总是在做很酷的事情
19
00:00:55,021 --> 00:00:57,622
reality and machine learning and all these things.
比如今年的虚拟(增强)现实和机器学习
20
00:00:57,691 --> 00:01:00,725
And there are millions of apps on the app store, so there's
同时 App Store 里有成千上万的程序
21
00:01:00,794 --> 00:01:03,428
a lot of people doing this stuff. But you're also gonna
很多人都在做 iOS 开发。同时你会
22
00:01:03,497 --> 00:01:05,263
learn in this class a little bit of real life
在这节课中学习到实际运用
23
00:01:05,332 --> 00:01:06,965
Object-Oriented Programming.
面向对象编程
24
00:01:07,034 --> 00:01:10,134
You all are taking classes, networking and databases and
你在其他计算机课程中学习到了网络,数据库
25
00:01:10,203 --> 00:01:13,238
graphics, your other CS classes. And here we're gonna
图形等,在这里你将会
26
00:01:13,306 --> 00:01:15,807
do all those things in a real life platform.
在 iOS 平台上实际运用这些
27
00:01:15,876 --> 00:01:19,177
Because over the weeks we are going to do all of those
因为这几周的时间我们会
28
00:01:19,246 --> 00:01:22,480
computer science things for real. And especially
实际运用这些计算机相关的知识
29
00:01:22,549 --> 00:01:25,684
Object-Oriented Programming, cuz iOS is completely and
特别是面向对象编程,因为 iOS
30
00:01:25,753 --> 00:01:29,053
utterly object-oriented. You cannot develop for
是完全面向对象的。除非你掌握了面向对象编程
31
00:01:29,122 --> 00:01:32,357
iOS without being serious object oriented programmer.
否则你不可能开发 iOS 程序
32
00:01:32,426 --> 00:01:34,960
And that brings me to my prerequisite for this course,
正好我可以讲讲上这门课的前提
33
00:01:35,029 --> 00:01:37,496
which is Object-Oriented Programming. You have to be
其中之一是面向对象编程
34
00:01:37,564 --> 00:01:39,631
comfortable with Object-Oriented Programming.
你必须要适应面向对象编程
35
00:01:39,699 --> 00:01:42,835
Definitely CS106 A and B and hopefully CS108,
必须要上了 CS106 A/B,最好是 CS108
36
00:01:42,903 --> 00:01:45,704
which is Object-Oriented Programming here at
这些是斯坦福开设的面向对象编程课程
37
00:01:45,773 --> 00:01:48,573
Stanford. And the other thing you gotta to be comfortable
其他你需要能适应的是
38
00:01:48,641 --> 00:01:51,343
with is writing a lot of code. All your homework in this
写很多代码。这节课所有的作业
39
00:01:51,412 --> 00:01:53,912
class, there's a little bit of reading the first few weeks
前几周还会有些关于我们
40
00:01:53,981 --> 00:01:56,047
about the language that we're gonna develop in.
开发要用的语言的阅读作业
41
00:01:56,116 --> 00:01:58,082
But mostly it's just programming, programming and
但其他的大部分都是写程序,写程序
42
00:01:58,151 --> 00:02:01,320
more programming. So if you're not comfortable writing a lot
写更多的程序。所以如果你不能适应天天敲代码
43
00:02:01,388 --> 00:02:04,289
of code then this class, you might wanna wait until
那你应该等等再上这节课
44
00:02:04,358 --> 00:02:07,059
you've taken some other classes that ask you to
你可以先上其他要写很多代码的课
45
00:02:07,127 --> 00:02:09,962
write a lot of code before you dive in here.
然后再来上这节课
46
00:02:10,030 --> 00:02:13,164
So what's in iOS? What am I gonna be teaching you?
好,那么 iOS 里面都有些什么?我要教你什么?
47
00:02:13,233 --> 00:02:15,533
I've divided it here into four layers.
我们可以把 iOS 分成四层
48
00:02:15,602 --> 00:02:18,003
The bottom layer is near the hardware, and
最下面的一层最接近硬件
49
00:02:18,071 --> 00:02:21,840
the top layer is near the user. So at that bottom layer,
最上面一层最接近用户。所以最底下的一层
50
00:02:21,909 --> 00:02:25,710
you might be surprised to find out that iOS is Unix.
你会很惊奇的发现 iOS 其实是 Unix 系统
51
00:02:25,779 --> 00:02:29,614
It's a BSD variant of Unix. And so all of the stuff
BSD 版本的 Unix。所以所有的这些
52
00:02:29,683 --> 00:02:34,453
that's going on down there is all happening in C basically.
在这里运行的程序大多都是用 C 语言编写的
53
00:02:34,521 --> 00:02:38,156
Unix is mostly written in C, most of that stuff is in C.
Unix 几乎是用 C 语言写的,大部分都是
54
00:02:38,225 --> 00:02:41,460
I'm not gonna teach you anything at this layer.
我不会教你这个层面的内容
55
00:02:41,528 --> 00:02:42,760
This is an object-oriented class,
这节课是教面向对象的
56
00:02:42,829 --> 00:02:44,396
everything we do will be object-oriented.
我们要写的程序也都是面向对象的
57
00:02:44,465 --> 00:02:47,432
You will not see me teaching you anything down there,
你不会看到我教你这部分的内容
58
00:02:47,501 --> 00:02:50,968
The next layer up is called the Core Services layer.
在那一层之上是 Core Services 层
59
00:02:50,968 --> 00:02:51,968
all right?
是吧?
60
00:02:51,968 --> 00:02:54,939
This is an object-oriented layer on top of those lower
这一层是对下面那层服务的面向对象封装
61
00:02:55,008 --> 00:02:59,377
services. This I will be teaching you. So if we wanna
我会教你这一层的内容。如果我们想要
62
00:02:59,446 --> 00:03:02,547
do things like find out where the phone is on the planet or
做比如这个手机在地球上的什么位置
63
00:03:02,616 --> 00:03:05,817
find out its orientation or access some files in the file
或者设备的方向,或者访问文件系统
64
00:03:05,886 --> 00:03:09,320
system, we're gonna be using this layer right here and I'll
我们就需要用到这层,我会
65
00:03:09,389 --> 00:03:13,191
be teaching you all about this layer. Core Services layer.
教你使用这一层,Core Services 层所有的功能
66
00:03:13,259 --> 00:03:17,428
The next layer up, this is kind of not a strict layering,
再上面一层,这不是很严谨的分层
67
00:03:17,497 --> 00:03:20,665
but is the Media layer. Don't forget that your iPhone
但这层是媒体(Media)处理层,不要忘了你的 iPhone
68
00:03:20,733 --> 00:03:24,369
is essentially, originally an iPod with a phone in it. So
原本是可以打电话的 iPod
69
00:03:24,438 --> 00:03:27,739
it's got all kinds of media, video, audio,
所以它能够对各种媒体,比如视频,音频
70
00:03:27,807 --> 00:03:31,543
many different kinds, images, all this stuff. And
以及众多格式的图片等进行处理
71
00:03:31,611 --> 00:03:34,446
unfortunately this is a layer I'd love to teach you but
虽然我很想教你们这些内容,但不幸的是
72
00:03:34,515 --> 00:03:37,482
I have to cut something, so I'm not gonna talk much about
我必须要消减一些内容,所以我不会讲太多
73
00:03:37,550 --> 00:03:40,718
this layer, unfortunately. So I know some of you might be
这层的内容,真的很不幸。我知道你们中的有些人
74
00:03:40,787 --> 00:03:43,354
wanting to write a cool game that has 3D sound with TIE
会想要编很酷的程序,有 3D 环绕声伴随
75
00:03:43,423 --> 00:03:46,224
fighters ripping around from the back of you to the front.
(星球大战里的)钛战机从后面飞到前面
76
00:03:46,292 --> 00:03:49,060
And that's all possible, and quite straightforward to do,
这些都是可能的,而且实现很简单
77
00:03:49,128 --> 00:03:51,629
but in ten weeks I have to pick what I'm gonna teach you,
但是我必须要选择十周的时间我应该教你们什么
78
00:03:51,698 --> 00:03:54,832
and so I'm gonna focus on Core Services. And then this layer,
所以我会更加注重 Core Services 层的内容。最后一层
79
00:03:54,901 --> 00:03:58,803
which is Cocoa Touch. So Cocoa Touch is the UI layer of iOS.
也就是 Cocoa Touch 层,它负责 iOS 的用户界面
80
00:03:58,872 --> 00:04:00,305
This is where the buttons and
这一层是比如按钮
81
00:04:00,374 --> 00:04:02,507
the sliders, all those things are in. And
滑杆(Slider)等控件定义的地方
82
00:04:02,576 --> 00:04:05,943
there's also, really powerful objects here, like the MapKit
这一层还有其他强大的对象,比如 MapKit
83
00:04:06,012 --> 00:04:08,679
has a single object that you can just drop in your app
有个对象,你可以直接把它加到程序里
84
00:04:08,748 --> 00:04:11,583
that gives you pretty much the entire functionality of
然后你就有了整个
85
00:04:11,652 --> 00:04:15,053
the map's app inside a rectangle, inside your window.
地图程序的功能,呈现在窗口里的某个矩形里
86
00:04:15,121 --> 00:04:18,256
So, you're talking about a wide variety of UI stuff here
所以你会遇到各种 UI 控件
87
00:04:18,324 --> 00:04:21,660
and I'm gonna try and cover as much of this as I can. So
我会尽量多地讲解这一层的内容
88
00:04:21,728 --> 00:04:23,929
that's what you're gonna learn in this class.
这就是你会在这节课中学习到的内容
89
00:04:23,997 --> 00:04:26,965
The platform we're gonna develop on is Xcode 9, so
我们的开发平台是 Xcode 9
90
00:04:27,034 --> 00:04:29,568
you're all gonna need to download Xcode 9,
你需要从 Mac App Store 免费下载 Xcode 9
91
00:04:29,637 --> 00:04:32,471
it's free and it only runs on your Mac.
(千万别从百度云等第三方下载)注意只支持 Mac
92
00:04:32,539 --> 00:04:35,140
And, there's this other little app, Instruments, but it's
同时还有一个程序,Instruments
93
00:04:35,208 --> 00:04:37,776
really kind of just an add-on to Xcode 9. We're gonna do
Xcode 附带的程序,更像是插件。我们会
94
00:04:37,844 --> 00:04:41,212
everything in Xcode 9, source code, editing, debugging,
在 Xcode 9 中做所有的事情,写代码,编辑,调试
95
00:04:41,281 --> 00:04:44,515
all that stuff is gonna happen in Xcode 9. You're also gonna
这些都是在 Xcode 9 中完成。你同时还要
96
00:04:44,584 --> 00:04:47,986
have to learn a new language. iOS has two languages you can
学习一门新的语言。开发 iOS 有两种语言可以选择
97
00:04:48,054 --> 00:04:50,154
develop in, Objective-C and Swift.
一个是 Objective-C,一个是 Swift
98
00:04:50,223 --> 00:04:53,291
Swift is the newer one, that's the one I'm gonna teach you.
Swift 是更新的一个,同时也是我会教你的语言
99
00:04:53,360 --> 00:04:56,327
Everything you learn though in Swift, all about iOS,
所有你用 Swift 学到的关于 iOS 的知识
100
00:04:56,396 --> 00:04:59,264
will apply if you later wanna go learn Objective-C and
如果你之后决定学 Objective-C 都是可以用到的
101
00:04:59,332 --> 00:05:02,367
work for a company that is still writing in Objective-C,
也可以用在还在使用 Objective-C 的公司的程序里
102
00:05:02,436 --> 00:05:05,036
which is perfectly valid language to write in.
因为 Objective-C 也是可以独当一面的语言
103
00:05:05,105 --> 00:05:06,838
But Swift kind of a cool new language,
但是 Swift 是更潮的新语言
104
00:05:06,906 --> 00:05:09,107
I think you're really, really gonna like it.
我相信你会喜欢上它的
105
00:05:09,176 --> 00:05:12,310
If you're a serious Computer Scientist another language is
如果你是个认真的程序员的话,学习一门新语言
106
00:05:12,378 --> 00:05:15,513
like big yawn whatever. Just tell me what the syntax is,
你听了应该觉得这很简单,你告诉我语法
107
00:05:15,582 --> 00:05:18,316
tell me what they key fundamental mechanisms for
告诉我那些基本的,关键的
108
00:05:18,385 --> 00:05:21,319
designing with it are, and I'll learn it.
程序设计方法,然后我就去把它掌握了
109
00:05:21,388 --> 00:05:24,221
So, if you don't have that attitude towards languages,
如果你不能这样接受学习新语言
110
00:05:24,290 --> 00:05:27,158
you're gonna be kind of having trouble out in the real world
你在现实生活中就会有麻烦了
111
00:05:27,227 --> 00:05:29,161
being a programmer. And then of course,
不容易当好程序员。当然
112
00:05:29,229 --> 00:05:31,596
there's millions of what we call Frameworks in iOS.
iOS 里有很多被称为框架(Frameworks)的东西
113
00:05:31,664 --> 00:05:33,331
Frameworks are just collections of objects.
框架就是对象的集合
114
00:05:33,399 --> 00:05:36,234
Like the biggest one is UIKit, that's where buttons, and
最大的一个是 UIKit,里面有按钮
115
00:05:36,303 --> 00:05:38,769
sliders, and all that stuff is. Foundation is another
滑杆等那些控件。Foundation 框架
116
00:05:38,838 --> 00:05:41,640
big one. That's where a lot of that core services stuff I was
也不小,里面主要是 Core Services 层的内容
117
00:05:41,708 --> 00:05:44,141
talking about is. But there's the MapKit, Core Motion,
但同时还有 MapKit、Core Motion
118
00:05:44,210 --> 00:05:46,478
Core Data, Object Orient, Database, all kinds of them.
Core Data(面向对象数据库)等等框架
119
00:05:46,547 --> 00:05:49,513
And I'll try and get to as many of them as I can. And
我会尝试讲到尽量多的框架
120
00:05:49,582 --> 00:05:53,652
last but definitely not least, there is a Design Strategy for
最后一个,同样重要的,设计模式
121
00:05:53,721 --> 00:05:56,754
building iOS apps that you have to use.
用来开发 iOS 程序必须要用的
122
00:05:56,823 --> 00:05:59,290
This is not like an optional, here's a good idea, why don't
这并不是一个选项,或者某个很好的点子
123
00:05:59,359 --> 00:06:03,395
you design this way? You must design this way. It's called
建议你这样设计。不,你必须这样设计。它叫做
124
00:06:03,463 --> 00:06:06,331
MVC, Model View Controller. How many people have,
MVC,即 Model(模型)-View(视图)-Controller(控制器)
125
00:06:06,399 --> 00:06:09,634
some experience doing MVC in any other? Okay, it's not so
这里有多少人有使用过 MVC?好吧
126
00:06:09,703 --> 00:06:12,303
many this quarter. Usually I get half the people but
这学期没有那么多人。通常会有一半的人
127
00:06:12,372 --> 00:06:14,439
I'll be teaching all about MVC.
但我会教你们 MVC
128
00:06:14,507 --> 00:06:17,342
The start of lecture on Wednesday is gonna be a full
星期三一开始会详尽地
129
00:06:17,411 --> 00:06:21,345
coverage of MVC. What it is, how it works, all that stuff,
讲 MVC,包括它是什么,怎么工作的,等等
130
00:06:21,414 --> 00:06:25,584
all right? So now, I'm gonna dive right into a big demo
好吧?现在,我会开始一个大型的示例程序
131
00:06:25,652 --> 00:06:29,921
that's the best way to learn how to do iOS development is
最好的学习 iOS 开发的方法
132
00:06:29,990 --> 00:06:32,557
with a demo. Seeing it happen, we're gonna build
就是看实例。看着如何做的,我们会
133
00:06:32,625 --> 00:06:34,926
an application from scratch. This slide right here,
从头开始写一个程序。这页幻灯片
134
00:06:34,995 --> 00:06:36,628
is a slide for you to look at later, and
是给你们之后看的
135
00:06:36,696 --> 00:06:39,197
see, did I learn all these things, because I should have
对照检查下我是否学会了这些,因为我
136
00:06:39,266 --> 00:06:43,468
learned them today. This is not a slide to read now.
在今天的课上学了。你们不用现在看
137
00:06:43,536 --> 00:06:45,503
Since I'm not gonna get back to the slides,
因为我不会再回到幻灯片
138
00:06:45,572 --> 00:06:48,139
let me just say what's coming up real quick. You are gonna
我快速地讲讲之后的安排
139
00:06:48,208 --> 00:06:50,008
have a reading assignment that goes out today.
我今天会布置给你们阅读作业
140
00:06:50,077 --> 00:06:53,044
It's basically starting to read the manual on
要求基本就是开始阅读 Swift 的说明书
141
00:06:53,113 --> 00:06:55,780
Swift. So you can learn this new language. It'll be all
以此来学习这门新语言
142
00:06:55,849 --> 00:06:58,950
spreaded out over three maybe four weeks, so you don't have
我会给你们大概三到四周读完整本书
143
00:06:59,019 --> 00:07:00,918
too much reading all at once. But
我不会一次要求你读太多
144
00:07:00,987 --> 00:07:03,588
those reading assignments are gonna be in addition to
但是不止是阅读作业
145
00:07:03,657 --> 00:07:06,224
programming assignments. The reading assignments are going
你们还会有编程作业。阅读作业是周一布置
146
00:07:06,293 --> 00:07:07,792
to go out on Monday, they come back on Monday,
下周一交
147
00:07:07,861 --> 00:07:08,993
they're due the next Monday. And
阅读作业是下周一交
148
00:07:09,062 --> 00:07:11,029
then the program assignments go out on Wednesday and
编程作业是星期三布置
149
00:07:11,098 --> 00:07:12,997
then they're due the next Wednesday generally.
一般来说会是下周三交
150
00:07:13,066 --> 00:07:15,599
Okay, at least we'll start the quarter that way.
好,至少我们一开始是这样安排的
151
00:07:15,668 --> 00:07:17,636
On Friday, we have an optional section,
星期五的课是选修课
152
00:07:17,704 --> 00:07:20,138
it means optional that you don't have to go there.
你可上可不上
153
00:07:20,206 --> 00:07:22,841
The topics we're gonna cover are kind of additional, but
讲的主题也会是额外的内容
154
00:07:22,910 --> 00:07:24,943
this Friday is one is a big one, it's tips and
但这周五的很重要,是关于
155
00:07:25,011 --> 00:07:27,412
tricks of Xcode, including how to use the debugger.
Xcode 使用的提示和技巧,包括如何使用调试器
156
00:07:27,481 --> 00:07:29,747
So if you've never used the debugger in Xcode,
如果你从没有使用过 Xcode 的调试器
157
00:07:29,816 --> 00:07:31,115
this is a good one to go to, so
我推荐你来参加
158
00:07:31,184 --> 00:07:33,685
you can see how to use the debugger for your problem.
你能见识到如何用调试器解决问题
159
00:07:33,754 --> 00:07:36,220
If not, you know, it's a debugger, if you used other
如果你不想来的话,嘛,就是个调试器,如果用过了其他的
160
00:07:36,289 --> 00:07:39,356
debuggers, you could probably figure it out, but anyway, it
调试器的话,你应该能够自己琢磨出来
161
00:07:39,425 --> 00:07:42,427
says right there that it's in Hewlett 205, but I don't think
这里写着会在 Hewlett 205,但我并不觉得
162
00:07:42,495 --> 00:07:44,962
there's such a room. I think it might be in Hewlett 105.
有这么个教室。我认为应该在 Hewlett 105
163
00:07:45,031 --> 00:07:47,532
I don't know, watch Piazza and we'll tell you where it is.
我记不清了,注意看 Piazza 上我告诉你们的地址
164
00:07:47,601 --> 00:07:51,869
But it is gonna be 11:30 to 12:20. And so next week we'll
但时间是 11:30 到 12:20。下一周
165
00:07:51,938 --> 00:07:55,473
talk more about Swift and then launch into all of iOS,
我们会更多的讲 Swift,然后就完全是 iOS 了
166
00:07:55,541 --> 00:07:59,243
all right? So let's jump right into the demo here.
好吧?我现在就开始演示写程序
167
00:07:59,312 --> 00:08:02,447
And I apologize in advance for going fast on this demo,
我这里提前道歉,这个演示我会过得很快
168
00:08:02,516 --> 00:08:03,848
because we have a lot to cover, and
因为我们要讲的实在是太多了
169
00:08:03,916 --> 00:08:05,650
you're gonna find that in this course, in general,
而对于这门课来说,你会发现这是普遍现象
170
00:08:05,719 --> 00:08:08,153
I tend to go pretty quick, cuz I wanna teach you as much of
我一般讲得很快,因为我想要教你们更多的内容
171
00:08:08,222 --> 00:08:13,057
this stuff as I possibly can. All right,
能教多少教多少。好
172
00:08:13,126 --> 00:08:16,728
Xcode. Here's Xcode. I went to the Mac App Store.
打开 Xcode。这就是 Xcode,去 Mac App Store
173
00:08:16,797 --> 00:08:19,030
I searched Xcode, I found it. I downloaded it.
搜索 Xcode,找到并下载
174
00:08:19,099 --> 00:08:21,866
It was free, it doesn't cost me a dime to develop for
Xcode 是免费的,不用花一分钱就可以开发
175
00:08:21,935 --> 00:08:24,602
iOS. When you launch Xcode for the first time,
iOS 程序。当你打开 Xcode 的时候
176
00:08:24,671 --> 00:08:26,637
you're gonna get this thing right here. So
你就会看到这个欢迎界面
177
00:08:26,706 --> 00:08:29,340
we need to build an app. Now, I decided to show you the app
我们需要构建一个程序。我准备先给你们展示
178
00:08:29,408 --> 00:08:32,844
that I'm gonna build here in real life. So you see these
我这个程序在现实生活中是怎么玩的。你看到这些
179
00:08:32,912 --> 00:08:36,681
cards that I've very artfully taped up here? These cards
卡片,就是我粘在这里的这些?这些卡片
180
00:08:36,750 --> 00:08:39,584
are going to let me play a game called Concentration.
可以用来玩一个叫做翻牌(Concentration)的游戏
181
00:08:39,653 --> 00:08:42,654
How many people have heard of the game Concentration?
有多少人听说过翻牌这个游戏?
182
00:08:42,722 --> 00:08:45,389
Not too many. Okay, so Concentration is just a card
不是很多。好吧,翻牌这个游戏就是个卡牌游戏
183
00:08:45,458 --> 00:08:48,059
game. Behind these cards that are all face down,
这些正面朝下的卡片上
184
00:08:48,127 --> 00:08:50,395
there are some pictures, and the goal is for
都有某张图片,我们的目标是
185
00:08:50,463 --> 00:08:53,464
you to match the pictures up. So there's 12 cards,
找到相同的图片。这里有 12 张卡
186
00:08:53,533 --> 00:08:57,834
6 pairs of pictures, so I get to pick two cards at a time,
6 对图片。所以我一次挑选两张
187
00:08:57,903 --> 00:08:59,602
and if they match, I win, and
如果是相同的,我就赢了,然后
188
00:08:59,671 --> 00:09:01,138
the cards go away. If they don't match,
牌放一边。如果不一样
189
00:09:01,207 --> 00:09:04,008
I have to turn them back down and pick two other cards, and
我就需要把它们放回原处,然后重新选两张
190
00:09:04,077 --> 00:09:06,778
it's called Concentration cuz I have to concentrate on
这个游戏叫做 Concentration 是因为要集中注意力
191
00:09:06,847 --> 00:09:09,681
the ones that didn't match, so that later I can go back and
关注那些没有配对上的,然后之后来
192
00:09:09,750 --> 00:09:11,783
match them. So, let's just flip some cards over here.
配对。让我们翻开这里的某些卡片
193
00:09:11,852 --> 00:09:13,984
I'm gonna start with this one right here.
我先从这个开始
194
00:09:14,053 --> 00:09:15,687
I really don't know what's behind there, but let's see.
我并不知道后面印的是什么图案
195
00:09:15,756 --> 00:09:20,491
Okay, this one is a pair of purple bats.
好,这个是一对紫色的蝙蝠
196
00:09:20,560 --> 00:09:22,460
So now I'm trying to find another pair of purple bats,
我们需要找到另一对紫色蝙蝠
197
00:09:22,529 --> 00:09:25,529
let's try right here. I found them right away, okay.
让我们试试这里的这个。啊,马上就找到了
198
00:09:25,598 --> 00:09:27,699
So this is a match, I get some points.
所以这是相匹配的,我就得分了
199
00:09:27,767 --> 00:09:31,535
These come off the board. So now I'm searching for
然后就拿下来。现在我要找到更多能配对的
200
00:09:31,604 --> 00:09:35,240
more matches. All right, let's try this one right here. It's
让我们来试试这里的这个