-
Notifications
You must be signed in to change notification settings - Fork 21
/
231 Advanced CloudKit [English].srt
executable file
·4258 lines (3358 loc) · 81.8 KB
/
231 Advanced CloudKit [English].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:14,009 --> 00:00:15,104
hi welcome to the advanced class
2
00:00:16,085 --> 00:00:20,116
shin
3
00:00:21,016 --> 00:00:21,113
thank you arm
4
00:00:22,013 --> 00:00:25,064
my name's Jacob Vargas I'm a software
engineer at Apple and one of the
5
00:00:25,064 --> 00:00:26,121
designers at the Clark API
6
00:00:27,021 --> 00:00:30,107
and my colleagues and I put a lot of
hard work into the club kid API
7
00:00:31,007 --> 00:00:34,045
and I'm really excited talk to guys
about it today so let's jump right into
8
00:00:34,045 --> 00:00:34,071
it
9
00:00:34,071 --> 00:00:37,107
so Clark it is
10
00:00:38,007 --> 00:00:41,044
this thing that we've built on top over
I cloud servers
11
00:00:41,044 --> 00:00:45,109
we build a lot of my cloud services and
what we're doing with Clark it is
12
00:00:46,009 --> 00:00:47,097
exposing those database servers
13
00:00:47,097 --> 00:00:50,129
that we use at Apple to all love you
developers
14
00:00:51,029 --> 00:00:56,008
I so we're actually using this this is
something that we use in the new i cud
15
00:00:56,269 --> 00:00:59,040
photos and i cud right feature that
we're introducing
16
00:00:59,004 --> 00:01:04,015
and we're building all that on topic
like it if all this is
17
00:01:04,015 --> 00:01:07,076
unfamiliar to you might want to go back
and check out the introducing crockett
18
00:01:07,076 --> 00:01:07,135
session
19
00:01:08,035 --> 00:01:11,063
I was given on Tuesday and there should
be videos online
20
00:01:11,063 --> 00:01:14,412
so we're gonna jump right into this I
21
00:01:14,979 --> 00:01:18,140
what we're gonna learn today we're gonna
go over the clark et private database
22
00:01:18,014 --> 00:01:20,068
which is a way for you to store private
user information
23
00:01:20,068 --> 00:01:23,153
in my class we're gonna talk about
modeling your data in cloud kit
24
00:01:24,053 --> 00:01:28,096
I we're gonna talk about Advance record
manipulation in different ways of saving
25
00:01:28,096 --> 00:01:29,124
records to the server
26
00:01:30,024 --> 00:01:34,028
we're gonna go over how to handle
notifications reliably
27
00:01:34,028 --> 00:01:39,028
I a few miss a push what to do and
finally we're gonna go over the Eichler
28
00:01:39,028 --> 00:01:42,126
dashboard which is a web-based interface
for managing a club kid application
29
00:01:43,026 --> 00:01:48,111
so let's start off by looking at the
clock API really quick
30
00:01:49,011 --> 00:01:53,065
we designed the clerk API to be highly a
synchronous
31
00:01:53,065 --> 00:01:56,150
everything has a call back on nothing is
synchronous
32
00:01:57,005 --> 00:02:00,062
and we did this because all these
requests are going out over the network
33
00:02:01,007 --> 00:02:04,596
I when you get the network involved
anything can happen you know the server
34
00:02:04,659 --> 00:02:08,190
might not be responding quickly there
might be a bad network connection
35
00:02:08,019 --> 00:02:11,083
I we don't want to block the UI and
cause a better user experience
36
00:02:11,083 --> 00:02:16,072
and to help do this we've used and its
operation almost everywhere in our API
37
00:02:16,819 --> 00:02:22,080
I I say almost everywhere because if you
went to the introductory session you
38
00:02:22,008 --> 00:02:24,637
remember seen what I we called the
convenience API
39
00:02:24,709 --> 00:02:28,530
and the convenience API is our way of
helping you get
40
00:02:28,053 --> 00:02:32,147
started with Clark it really quickly and
simply are all these APIs are
41
00:02:33,047 --> 00:02:37,094
you know single calls at work on are one
record at the time so in this case were
42
00:02:37,094 --> 00:02:38,129
fetching one record
43
00:02:39,029 --> 00:02:43,042
and its a synchronous we get that one
record back in our completion handler
44
00:02:43,042 --> 00:02:46,109
but as he's clock it more you might find
that you need some additional
45
00:02:47,009 --> 00:02:48,018
functionality
46
00:02:48,018 --> 00:02:51,050
and that's where the NS operation based
API comes in
47
00:02:51,005 --> 00:02:55,016
so what we've got here is the CK fetch
records operation
48
00:02:55,061 --> 00:02:59,078
and this is an NS operation that does
the equipment at their convenience API
49
00:02:59,078 --> 00:02:59,154
we just saw
50
00:03:00,054 --> 00:03:03,069
we give you a lot more functionality
when you use the
51
00:03:03,069 --> 00:03:06,090
Ennis operation base API so you can see
here that
52
00:03:06,009 --> 00:03:09,053
are initializer takes a array record
ID's
53
00:03:10,034 --> 00:03:15,065
you can fetch a whole batch records all
at once we also give your feedback on
54
00:03:15,065 --> 00:03:19,014
what's happening we've got a completion
block for each record and we also give
55
00:03:19,599 --> 00:03:22,300
you progress as we download those
records from the server
56
00:03:22,003 --> 00:03:26,049
and finally these operations give you
more
57
00:03:26,076 --> 00:03:30,085
knobs and levers to tweak what what is
returned in what the operation does
58
00:03:31,066 --> 00:03:35,645
on this case we've got a desired keys
property the lets you specify what he
59
00:03:36,239 --> 00:03:38,120
should come back on the records if you
catch
60
00:03:38,012 --> 00:03:44,027
so since all this is built on and its
operation let's do a quick overview of
61
00:03:44,027 --> 00:03:44,034
what the
62
00:03:44,097 --> 00:03:48,696
and its operation class looks like are
what we got in and its operation is a
63
00:03:49,569 --> 00:03:50,970
completion block Anne
64
00:03:50,097 --> 00:03:53,196
cancel call so that you can manage the
life cycle your operation
65
00:03:54,069 --> 00:03:58,760
we've got a couple variables that tell
you some state about the operation
66
00:03:58,076 --> 00:04:01,098
and and its operations have dependencies
67
00:04:01,098 --> 00:04:07,127
seek and linked to Anna separations
together what you have in its operation
68
00:04:08,027 --> 00:04:10,108
you're going to want to start that
operation and you do that by
69
00:04:11,008 --> 00:04:16,697
adding it to A&S operation cue when you
have an ass operation cue you can also
70
00:04:16,769 --> 00:04:16,827
manage
71
00:04:17,349 --> 00:04:20,435
the life cycle that operation cue you
can suspended and resume it
72
00:04:21,209 --> 00:04:27,660
and you can cancel the operations and so
if you go to look at her and its
73
00:04:27,066 --> 00:04:30,124
operation base API you might just see
this big list I have a bunch a different
74
00:04:31,024 --> 00:04:34,133
operations it's kinda overwhelming and
confusing
75
00:04:34,349 --> 00:04:37,355
are the best way to think about this API
is to think about the
76
00:04:37,409 --> 00:04:41,770
objects that you want to deal with I
remember from the introductory talk
77
00:04:41,077 --> 00:04:45,616
I clarke its base objects are records
and zones and subscriptions
78
00:04:46,309 --> 00:04:50,334
and you'll see that up here we have a
factional modify operation for all those
79
00:04:50,559 --> 00:04:54,632
items
80
00:04:55,289 --> 00:04:58,338
one other really cool things about and
its operation is that has dependencies
81
00:04:58,779 --> 00:05:01,830
I so you can set a dependency between
two operations
82
00:05:02,289 --> 00:05:06,800
and the second operation won't fire
until the first operation is completed
83
00:05:06,008 --> 00:05:10,187
%uh this is really handy with cloud kid
if you want to do something like fetch a
84
00:05:10,979 --> 00:05:12,020
record
85
00:05:12,002 --> 00:05:15,511
at a property to it and say that record
back to the server
86
00:05:15,529 --> 00:05:18,627
you can make the fetch records operation
make the Modify operation at the same
87
00:05:19,509 --> 00:05:19,606
time
88
00:05:20,479 --> 00:05:24,210
set up a dependency and when the feds
completes you can put that date in the
89
00:05:24,021 --> 00:05:28,065
Modify operation and it'll start
automatically
90
00:05:28,065 --> 00:05:32,484
these dependencies also work between
cues so even though Clark it has its own
91
00:05:33,069 --> 00:05:34,650
internal operation cue
92
00:05:34,065 --> 00:05:37,984
that you can use run operations your
welcome to to create your own and its
93
00:05:38,569 --> 00:05:39,594
operation cue
94
00:05:39,819 --> 00:05:42,891
and you can then manage its life cycle
you can stop operations are spending
95
00:05:43,539 --> 00:05:47,577
more cancel them
96
00:05:47,919 --> 00:05:51,930
I want one tip with using them and its
operation though is that the
97
00:05:51,093 --> 00:05:54,942
and its operation base class has a
completion block on it
98
00:05:55,779 --> 00:05:58,861
this completion block ends a fire in a
synchronously with dependencies
99
00:05:59,599 --> 00:06:03,631
30 setup dependencies n you using the
and its operations completion block
100
00:06:03,919 --> 00:06:07,006
they might happen at the same time and
that data you're trying to funnel into
101
00:06:07,789 --> 00:06:10,360
the next operation won't get there in
time
102
00:06:10,036 --> 00:06:13,115
you know that operation is already
started so what we've done with the
103
00:06:13,439 --> 00:06:14,430
crowd get a PI
104
00:06:14,043 --> 00:06:17,043
is we have clout get specific completion
box
105
00:06:17,043 --> 00:06:20,068
and if we look at are what we had for
that fetch records
106
00:06:20,068 --> 00:06:23,707
operation we have a fat records
completion block
107
00:06:24,319 --> 00:06:27,368
are you'll see this pattern on all over
and its operations and these completion
108
00:06:27,809 --> 00:06:28,842
blocks hand back
109
00:06:29,139 --> 00:06:32,800
all the information you need to know
about the operation it just ran
110
00:06:32,008 --> 00:06:36,052
in this case we've got the heirs for
that operation and we've also got the
111
00:06:37,024 --> 00:06:40,253
records that were fetched
112
00:06:40,469 --> 00:06:44,020
and finally and its operations can have
their own priorities so you can set
113
00:06:44,002 --> 00:06:46,011
background operations and have a
runnable
114
00:06:46,011 --> 00:06:50,650
really low priority and keep your UI
responsive
115
00:06:50,749 --> 00:06:53,710
so when we were designing cloud kid
wanna things we noticed is that there's
116
00:06:53,071 --> 00:06:55,810
two general classes applications
117
00:06:56,449 --> 00:07:00,490
there's one class application that
stores a whole buncha data up on the
118
00:07:00,049 --> 00:07:01,028
server
119
00:07:01,469 --> 00:07:04,492
and when you use the application it's
just presenting a viewer that data it
120
00:07:04,699 --> 00:07:06,460
downloaded on demand
121
00:07:06,046 --> 00:07:10,055
displayed to the user and then you know
tosses it out because it's the real
122
00:07:10,469 --> 00:07:12,240
copies on the server
123
00:07:12,024 --> 00:07:15,086
but there's another class application
that has just a little bit data
124
00:07:15,086 --> 00:07:18,171
but you want that same data on all the
clients
125
00:07:19,071 --> 00:07:22,240
so if you remember from the introductory
talk we talked about that what we call
126
00:07:22,879 --> 00:07:23,923
Big Data little fun
127
00:07:24,319 --> 00:07:27,382
that's the case where we have a lot to
date on the server it's not all gonna
128
00:07:27,949 --> 00:07:28,991
fit on one phone
129
00:07:29,369 --> 00:07:32,395
and you downloaded and viewed on demand
so you can see these
130
00:07:32,629 --> 00:07:35,740
clients are downloading records feeling
I'm and
131
00:07:35,074 --> 00:07:38,105
the truth lives up on the server
132
00:07:39,005 --> 00:07:42,494
however there's another class
application where
133
00:07:42,539 --> 00:07:45,614
it's a small amount of data it lives on
one client but you wanted on all your
134
00:07:46,289 --> 00:07:46,352
clients
135
00:07:46,919 --> 00:07:49,961
i an example this is an application that
manages the receipts
136
00:07:50,339 --> 00:07:54,425
so I every time you buy something you
take pictures 3 seed
137
00:07:55,199 --> 00:07:59,252
and you want that information on your
phone in your iPad and your Mac
138
00:07:59,729 --> 00:08:04,827
and you want them all to be up to date
with the same receipts
139
00:08:05,709 --> 00:08:09,727
so what we've done to help you solve
that is we've got something in car kit
140
00:08:09,889 --> 00:08:09,945
that does a
141
00:08:10,449 --> 00:08:14,480
a if you remember we have every
application its container
142
00:08:14,759 --> 00:08:17,786
in every container is a public and
private database
143
00:08:18,029 --> 00:08:21,054
and just a as a refresher that private
databases
144
00:08:21,279 --> 00:08:25,366
actually one private database for every
user
145
00:08:26,149 --> 00:08:29,177
insiders the bases we then subdivided
down into zones
146
00:08:29,429 --> 00:08:33,527
so both the public and the private
database have a default on them
147
00:08:34,409 --> 00:08:38,990
but we've also given you what we call
customs and these custom zones allow us
148
00:08:38,099 --> 00:08:40,768
to give me some extra features that we
can't provide
149
00:08:41,659 --> 00:08:46,700
in the default I'll you can create these
custom zones and
150
00:08:46,007 --> 00:08:50,008
use the new features I let's go over
couple
151
00:08:50,008 --> 00:08:53,081
%uh the first feature is atomic commits
152
00:08:54,053 --> 00:08:58,104
so Clark it has relationships between
records and if you start using cloud kid
153
00:08:59,004 --> 00:09:01,078
and using these relationships are gonna
build up an object
154
00:09:01,078 --> 00:09:04,127
object graph and you're gonna realize
you want consistency
155
00:09:05,027 --> 00:09:09,048
in your data I if you know you might
have an object graph that you want to
156
00:09:09,048 --> 00:09:10,062
commit all at once
157
00:09:10,062 --> 00:09:13,140
and if some other things don't get
committed the date on the server doesn't
158
00:09:14,004 --> 00:09:15,096
make sense
159
00:09:16,032 --> 00:09:19,126
on the public database we can guarantee
that because there might be thousands or
160
00:09:20,026 --> 00:09:22,030
millions of users hidden same database
161
00:09:22,003 --> 00:09:26,010
so there's no way to lock the database
while we you know commit your very
162
00:09:26,037 --> 00:09:27,090
special records
163
00:09:27,009 --> 00:09:30,092
but in the private database you only
have one user its
164
00:09:31,073 --> 00:09:35,092
the current user's account and in that
case we can provide you things like
165
00:09:35,092 --> 00:09:39,159
atomic commits
166
00:09:40,059 --> 00:09:44,084
so with atomic commits these batch
operations in the end its operation API
167
00:09:44,084 --> 00:09:47,085
will succeed or fail as a whole so if
168
00:09:47,085 --> 00:09:50,086
any record had a problem you will get
back
169
00:09:50,095 --> 00:09:53,156
a CK air partial failure
170
00:09:54,056 --> 00:09:57,121
inside that partial failure air you're
gonna see a user the user info
171
00:09:58,021 --> 00:09:59,105
dictionary is gonna have this
172
00:10:00,005 --> 00:10:03,040
seek a partial errors by item id:
173
00:10:03,004 --> 00:10:06,042
and that's going to be a dictionary
record ID's to
174
00:10:06,078 --> 00:10:10,099
errors for each of those records and
some of those areas are going to be
175
00:10:10,099 --> 00:10:13,100
the real failures that you care about
these are the reasons that the atomic
176
00:10:14,000 --> 00:10:15,036
commit failed
177
00:10:15,036 --> 00:10:18,075
but you know the rest of the records
fail because it was atomic commit
178
00:10:18,075 --> 00:10:22,078
and we need to let you know that they
failed see also gonna CCK air bats
179
00:10:22,078 --> 00:10:23,131
request failed
180
00:10:24,031 --> 00:10:27,060
that's just the way of saying that
something else in this batch failed and
181
00:10:27,006 --> 00:10:28,055
you know this wasn't the real problem
182
00:10:29,009 --> 00:10:32,095
it was that other record in here
183
00:10:32,095 --> 00:10:36,194
another great feature that we give you
with custom zones our Delta downloads
184
00:10:37,094 --> 00:10:41,095
so Delta downloads our way for that
second class application
185
00:10:41,095 --> 00:10:44,109
to be possible in Crockett I you can
download
186
00:10:45,009 --> 00:10:50,066
only the changes that were made in that
zone and you can catch them all locally
187
00:10:50,066 --> 00:10:53,132
so what does that look like well we've
got our Mac here
188
00:10:54,032 --> 00:10:57,094
we've got a iphone and we've got a
customs up
189
00:10:57,094 --> 00:11:00,136
so let's step through a delta download
really quick we got
190
00:11:01,036 --> 00:11:04,083
in orange record in a green record over
on the Mac here and we want them on the
191
00:11:04,083 --> 00:11:05,086
phone as well
192
00:11:05,086 --> 00:11:09,181
so we're gonna first upload those both
in the car kit in our customs own
193
00:11:10,081 --> 00:11:16,177
and then are iPhone is gonna perform a
delta download to get up-to-date
194
00:11:17,077 --> 00:11:20,089
cities doctor downloads are based on
what we call change tokens
195
00:11:20,089 --> 00:11:23,147
and a change took it as a way of
tracking the state the server the last
196
00:11:24,047 --> 00:11:25,119
time you talked to it
197
00:11:26,019 --> 00:11:29,028
so this phone has never talk to the
server and
198
00:11:29,028 --> 00:11:31,106
what it's going to do is send up a new
change token and that's the way of
199
00:11:32,006 --> 00:11:36,010
saying I'm never talk to you to send me
all the records in the cell
200
00:11:36,001 --> 00:11:40,037
so the service going to take that no
change token send down and/or the orange
201
00:11:40,046 --> 00:11:41,089
record in green record
202
00:11:41,089 --> 00:11:44,143
the phone is gonna save them into its
local database and then the servers
203
00:11:45,043 --> 00:11:46,134
gonna send out a new change token
204
00:11:47,034 --> 00:11:50,063
on this case it's changed okay and that
means that
205
00:11:50,063 --> 00:11:53,151
you know the records you have are all
from state a
206
00:11:54,051 --> 00:11:57,080
if the phone came back again with change
taking a the server will go well I don't
207
00:11:57,008 --> 00:11:58,031
have anything for you
208
00:11:59,003 --> 00:12:03,056
is good enough there's nothing to
download
209
00:12:03,056 --> 00:12:06,059
but let's say the Mac comes along and it
creates that purple record
210
00:12:06,086 --> 00:12:10,169
and it deletes the green record and it
upload those changes to the server
211
00:12:11,069 --> 00:12:14,101
the servers go to track the changes so
it'll note that that green record was