This repository was archived by the owner on Jan 27, 2025. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.rdf
2089 lines (1670 loc) · 198 KB
/
index.rdf
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
<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">
<channel>
<title>Objective-C Runtime in Pictures</title>
<description>How your sourcecode ends up in the Objective-C runtime - The Mulle Way.</description>
<link>https://www.mulle-kybernetik.com/</link>
<atom:link href="https://www.mulle-kybernetik.com/atom.xml" rel="self" type="application/rss+xml"/>
<pubDate>Sun, 26 Jan 2025 22:58:03 +0100</pubDate>
<lastBuildDate>Sun, 26 Jan 2025 22:58:03 +0100</lastBuildDate>
<generator>Jekyll v4.3.4</generator>
<item>
<title></title>
<description><style type="text/css" media="screen">
.container {
margin: 10px auto;
max-width: 600px;
text-align: center;
}
h1 {
margin: 30px 0;
font-size: 4em;
line-height: 1;
letter-spacing: -1px;
}
</style>
<div class="container">
<h1>404</h1>
<p><strong>Page not found :(</strong></p>
<p>The requested page could not be found.</p>
</div>
</description>
<pubDate></pubDate>
<link>https://www.mulle-kybernetik.com/404.html</link>
<guid isPermaLink="true">https://www.mulle-kybernetik.com/404.html</guid>
</item>
<item>
<title></title>
<description><?xml version="1.0" encoding="utf-8"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
<title type="text">Objective-C Runtime in Pictures</title>
<generator uri="https://github.com/jekyll/jekyll">Jekyll</generator>
<link rel="self" type="application/atom+xml" href="https://www.mulle-kybernetik.com/atom.xml" />
<link rel="alternate" type="text/html" href="https://www.mulle-kybernetik.com" />
<updated>2025-01-26T22:58:03+01:00</updated>
<id>https://www.mulle-kybernetik.com/</id>
<author>
<name>Nat!</name>
<uri>https://www.mulle-kybernetik.com/</uri>
</author>
<entry>
<title type="html"><![CDATA[Appendix]]></title>
<link rel="alternate" type="text/html" href="https://www.mulle-kybernetik.com/appendix.html" />
<id>https://www.mulle-kybernetik.com/appendix.html</id>
<published>2024-12-01T00:00:00+01:00</published>
<updated>2024-12-01T00:00:00+01:00</updated>
<author>
<name>Nat!</name>
<uri>https://www.mulle-kybernetik.com</uri>
</author>
<content type="html">&lt;h2 id=&quot;syntax-topic&quot;&gt;Syntax topic&lt;/h2&gt;
&lt;div class=&quot;language-objective-c highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;p&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;obj&lt;/span&gt; &lt;span class=&quot;nf&quot;&gt;methodWithArgument&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;argument&lt;/span&gt; &lt;span class=&quot;nf&quot;&gt;additionalArgument&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:];&lt;/span&gt;
&lt;span class=&quot;p&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;super&lt;/span&gt; &lt;span class=&quot;nf&quot;&gt;method&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;argument&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;];&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;
&lt;h2 id=&quot;method-call&quot;&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;[method call]&lt;/code&gt;&lt;/h2&gt;
&lt;p&gt;When you invoke or call an Objective-C method on an object, the object is
the &lt;strong&gt;receiver&lt;/strong&gt; of a message. This is just nomenclature.&lt;/p&gt;
&lt;p&gt;The receiver appears first in the method call, followed by the selector
interspersed with arguments in square brackets. So a call to method &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;- (void) insertObject:(id) obj atIndex:(NSUInteger) index&lt;/code&gt; will look like this:&lt;/p&gt;
&lt;p&gt;&lt;a href=&quot;images/method-call.svg&quot;&gt;&lt;img src=&quot;images/method-call.svg&quot; alt=&quot;Method call deconstructed&quot; /&gt;&lt;/a&gt;&lt;/p&gt;
&lt;h3 id=&quot;method-search&quot;&gt;Method search&lt;/h3&gt;
&lt;p&gt;So what does a method call do ? First it looks at the &lt;a href=&quot;https://alwaysprocessing.blog/2023/01/19/objc-class-isa&quot;&gt;isa&lt;/a&gt;
pointer of the object. This will be a pointer to a &lt;a href=&quot;class.html&quot;&gt;class&lt;/a&gt; object.
The class has
at least one methodlist. It can have multiple methodlists, if some were added
by &lt;a href=&quot;category.html&quot;&gt;categories&lt;/a&gt;. The search order goes from back to front, so the most
recently added category methodlist comes first.&lt;/p&gt;
&lt;p&gt;If no method has been found, the class may inherit methodlists from its
&lt;a href=&quot;protocolclass.html&quot;&gt;protocolclasses&lt;/a&gt; and its &lt;a href=&quot;inheritance.html&quot;&gt;superclass&lt;/a&gt;.
Again, the search order is back to first, the latest defined protocolclass is
searched first, then the others and the superclass last.&lt;/p&gt;
&lt;p&gt;The superclass itself can be the same mixture of categories, protocolclasses
and a possible superclass.&lt;/p&gt;
&lt;p&gt;Finally after the rootclass has been reached, and no method has been found yet,
the runtime will turn to forwarding (not part of this pamphlet) and if that
fails, the runtime will crash.&lt;/p&gt;
&lt;h3 id=&quot;super-method-search&quot;&gt;Super method search&lt;/h3&gt;
&lt;p&gt;The special super call, starts the message search from the “place” of
implementation. It will ignore all sibling methodlists of its implementation
class and then start a regular method search in the protocolclasses
and superclass.&lt;/p&gt;
&lt;h3 id=&quot;clobber-method-search&quot;&gt;Clobber method search&lt;/h3&gt;
&lt;p&gt;Only available with MulleObjC C runtime functions. This search stops at the
implementation class boundary. It searches backwards from the current
methodlist.&lt;/p&gt;
&lt;h3 id=&quot;override-method-search&quot;&gt;Override method search&lt;/h3&gt;
&lt;p&gt;Like the Clobber method search, but does not stop at the class boundary.&lt;/p&gt;
&lt;h2 id=&quot;case-studies&quot;&gt;Case studies&lt;/h2&gt;
&lt;p&gt;&lt;em&gt;Only instance methodlists are shown for simplicity.&lt;/em&gt;&lt;/p&gt;
&lt;h3 id=&quot;class-a-the-simplest-case&quot;&gt;Class A, the simplest case&lt;/h3&gt;
&lt;p&gt;&lt;strong&gt;A&lt;/strong&gt; contains a method &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;instanceMethod&lt;/code&gt;, its &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;@implementation&lt;/code&gt; is not shown,
as it’s boring:&lt;/p&gt;
&lt;div class=&quot;language-objective-c highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;k&quot;&gt;@interface&lt;/span&gt; &lt;span class=&quot;nc&quot;&gt;A&lt;/span&gt;
&lt;span class=&quot;k&quot;&gt;-&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;kt&quot;&gt;void&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;instanceMethod&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt;
&lt;span class=&quot;k&quot;&gt;@end&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;
&lt;p&gt;&lt;a href=&quot;images/A.svg&quot;&gt;&lt;img src=&quot;images/A.svg&quot; alt=&quot;A&quot; /&gt;&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;This is just for warming up. There is no &lt;strong&gt;super&lt;/strong&gt; method in a root class,
and nothing has been overridden. So its &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;-instanceMethod&lt;/code&gt; only.&lt;/p&gt;
&lt;h3 id=&quot;subclass-b-of-a-and-categories-on-b&quot;&gt;Subclass B of A and categories on B&lt;/h3&gt;
&lt;p&gt;B overrides the superclass method &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;instanceMethod&lt;/code&gt;. And so do the two
categories P and Q on B. Again, implementations are not shown:&lt;/p&gt;
&lt;div class=&quot;language-objective-c highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;k&quot;&gt;@interface&lt;/span&gt; &lt;span class=&quot;nc&quot;&gt;B&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;nc&quot;&gt;A&lt;/span&gt;
&lt;span class=&quot;k&quot;&gt;-&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;kt&quot;&gt;void&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;instanceMethod&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt;
&lt;span class=&quot;k&quot;&gt;@end&lt;/span&gt;
&lt;span class=&quot;k&quot;&gt;@interface&lt;/span&gt; &lt;span class=&quot;nc&quot;&gt;B&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt; &lt;span class=&quot;nl&quot;&gt;P&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
&lt;span class=&quot;k&quot;&gt;-&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;kt&quot;&gt;void&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;instanceMethod&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt;
&lt;span class=&quot;k&quot;&gt;@end&lt;/span&gt;
&lt;span class=&quot;k&quot;&gt;@interface&lt;/span&gt; &lt;span class=&quot;nc&quot;&gt;B&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt; &lt;span class=&quot;nl&quot;&gt;Q&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
&lt;span class=&quot;k&quot;&gt;-&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;kt&quot;&gt;void&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;instanceMethod&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt;
&lt;span class=&quot;k&quot;&gt;@end&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;
&lt;p&gt;this will result in more complex layout:&lt;/p&gt;
&lt;p&gt;&lt;a href=&quot;images/B.svg&quot;&gt;&lt;img src=&quot;images/B.svg&quot; alt=&quot;B&quot; /&gt;&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;As explained before, the search order will be from back to front.
So &lt;em&gt;methodlist #2&lt;/em&gt; of B comes first, then &lt;em&gt;methodlist #1&lt;/em&gt; of B, then
&lt;em&gt;methodlist #0&lt;/em&gt; of B. The final search is through &lt;em&gt;methodlist #0&lt;/em&gt; of A.&lt;/p&gt;
&lt;p&gt;In short notation the various searches result in:&lt;/p&gt;
&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt; super chain: B(Q) -&amp;gt; A
clobber chain: B(Q) -&amp;gt; B(P) -&amp;gt; B
override chain: B(Q) -&amp;gt; B(P) -&amp;gt; B -&amp;gt; A
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;
&lt;h3 id=&quot;subclass-c-of-b-and-multiple-inheritance-with-protocolclasses&quot;&gt;Subclass C of B and multiple inheritance with protocolclasses&lt;/h3&gt;
&lt;p&gt;The next class &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;C&lt;/code&gt; builds on &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;B&lt;/code&gt; and has two protocolclasses added to the mix:&lt;/p&gt;
&lt;div class=&quot;language-objc highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;k&quot;&gt;@protocol&lt;/span&gt; &lt;span class=&quot;nc&quot;&gt;X&lt;/span&gt;
&lt;span class=&quot;k&quot;&gt;@end&lt;/span&gt;
&lt;span class=&quot;k&quot;&gt;@interface&lt;/span&gt; &lt;span class=&quot;nc&quot;&gt;X&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;X&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;&amp;gt;&lt;/span&gt;
&lt;span class=&quot;k&quot;&gt;@end&lt;/span&gt;
&lt;span class=&quot;k&quot;&gt;@protocol&lt;/span&gt; &lt;span class=&quot;nc&quot;&gt;Y&lt;/span&gt;
&lt;span class=&quot;k&quot;&gt;@end&lt;/span&gt;
&lt;span class=&quot;k&quot;&gt;@interface&lt;/span&gt; &lt;span class=&quot;nc&quot;&gt;Y&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;Y&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;&amp;gt;&lt;/span&gt;
&lt;span class=&quot;k&quot;&gt;@end&lt;/span&gt;
&lt;span class=&quot;k&quot;&gt;@interface&lt;/span&gt; &lt;span class=&quot;nc&quot;&gt;C&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;nc&quot;&gt;B&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;&amp;lt;&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;X&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;Y&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;&amp;gt;&lt;/span&gt;
&lt;span class=&quot;k&quot;&gt;@end&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;
&lt;p&gt;The result looks like this:&lt;/p&gt;
&lt;p&gt;&lt;a href=&quot;images/C.svg&quot;&gt;&lt;img src=&quot;images/C.svg&quot; alt=&quot;C&quot; /&gt;&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;Now with methodlist of &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;C&lt;/code&gt; as the starting point, we get:&lt;/p&gt;
&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt; super chain: C -&amp;gt; Y -&amp;gt; X -&amp;gt; B(Q) -&amp;gt; A
clobber chain: C
override chain: C -&amp;gt; Y -&amp;gt; X -&amp;gt; B(Q) -&amp;gt; B(P) -&amp;gt; B -&amp;gt; A
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;
&lt;h3 id=&quot;class-d-inheritance-with-duplicate-protocolclasses&quot;&gt;Class D, inheritance with duplicate protocolclasses&lt;/h3&gt;
&lt;div class=&quot;language-objc highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;k&quot;&gt;@interface&lt;/span&gt; &lt;span class=&quot;nc&quot;&gt;D&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;nc&quot;&gt;C&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;&amp;lt;&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;Y&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;X&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;&amp;gt;&lt;/span&gt;
&lt;span class=&quot;k&quot;&gt;@end&lt;/span&gt;
&lt;span class=&quot;k&quot;&gt;@interface&lt;/span&gt; &lt;span class=&quot;nc&quot;&gt;D&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt; &lt;span class=&quot;nl&quot;&gt;P&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
&lt;span class=&quot;k&quot;&gt;@end&lt;/span&gt;
&lt;span class=&quot;k&quot;&gt;@interface&lt;/span&gt; &lt;span class=&quot;nc&quot;&gt;D&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt; &lt;span class=&quot;nl&quot;&gt;Q&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
&lt;span class=&quot;k&quot;&gt;@end&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;
&lt;p&gt;&lt;a href=&quot;images/D.svg&quot;&gt;&lt;img src=&quot;images/D.svg&quot; alt=&quot;D&quot; /&gt;&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;Before we go on, lets reconsider, that a protocolclass is a root class and
has no business calling “super” by itself. But if you were, here is what
would happen:&lt;/p&gt;
&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt; super chain: D(Q) -&amp;gt; X -&amp;gt; Y -&amp;gt; C -&amp;gt; Y -&amp;gt; C -&amp;gt; ... -&amp;gt; INFINITE LOOP CRASH
clobber chain: D(Q) -&amp;gt; D(P) -&amp;gt; D
override chain: D(Q) -&amp;gt; D(P) -&amp;gt; D -&amp;gt; X -&amp;gt; Y -&amp;gt; C -&amp;gt; Y -&amp;gt; C -&amp;gt; ... -&amp;gt; INFINITE LOOP CRASH
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;
&lt;hr /&gt;
&lt;h2 id=&quot;api&quot;&gt;API&lt;/h2&gt;
&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Method Name&lt;/th&gt;
&lt;th&gt;Description&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;-performSelector:&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Perform method taking no arguments&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;-performSelector:withObject:&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Perform method taking one argument&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;-performSelector:withObject:withObject:&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Perform method taking two arguments&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;
&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Function/Method Name&lt;/th&gt;
&lt;th&gt;Description&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;MulleObjCObjectPerformSelector0&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Call method with no arguments&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;MulleObjCObjectPerformSelector&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Call method with one argument&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;MulleObjCObjectPerformSelector2&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Call method with two arguments&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;MulleObjCIMPCall0&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Call implementation with no arguments&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;MulleObjCIMPCall&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Call implementation with one argument&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;MulleObjCIMPCall2&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Call implementation with two arguments&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;MulleObjCIMPCallWithFloat&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Call implementation with float argument&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;MulleObjCIMPCallWithDouble&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Call implementation with double argument&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;MulleObjCIMPCallWithLong&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Call implementation with long argument&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;MulleObjCMakeObjectsPerformSelector0&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Call method on array of objects with no args&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;MulleObjCMakeObjectsPerformSelector&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Call method on array of objects with one arg&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;MulleObjCMakeObjectsPerformSelector2&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Call method on array of objects with two args&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;MulleObjCObjectSearchSuperIMP&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Find superclass implementation of a method&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;MulleObjCObjectSearchSpecificIMP&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Find method implementation in specific class/category&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;MulleObjCObjectSearchOverriddenIMP&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Find overridden implementation of a method&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;MulleObjCObjectSearchClobberedIMP&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Find implementation clobbered by a category&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;
</content>
</entry>
<entry>
<title type="html"><![CDATA[Outro]]></title>
<link rel="alternate" type="text/html" href="https://www.mulle-kybernetik.com/outro.html" />
<id>https://www.mulle-kybernetik.com/outro.html</id>
<published>2024-11-30T00:00:00+01:00</published>
<updated>2024-11-30T00:00:00+01:00</updated>
<author>
<name>Nat!</name>
<uri>https://www.mulle-kybernetik.com</uri>
</author>
<content type="html">&lt;h2 id=&quot;how-to-create-your-own-runtime-pictures&quot;&gt;How to create your own runtime pictures&lt;/h2&gt;
&lt;p&gt;Create a new &lt;a href=&quot;https://mulle-objc.github.io/&quot;&gt;mulle-objc&lt;/a&gt; with
&lt;a href=&quot;https://github/mulle-sde&quot;&gt;mulle-sde&lt;/a&gt;:&lt;/p&gt;
&lt;div class=&quot;language-console highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;go&quot;&gt;mulle-sde init -d picture -m mulle-objc/objc-developer executable
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;
&lt;p&gt;Edit &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;src/main.m&lt;/code&gt; with a class hierarchy of your choice, then change &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;main&lt;/code&gt; to:&lt;/p&gt;
&lt;div class=&quot;language-c highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;kt&quot;&gt;int&lt;/span&gt; &lt;span class=&quot;nf&quot;&gt;main&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt; &lt;span class=&quot;kt&quot;&gt;int&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;argc&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;kt&quot;&gt;char&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;*&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;argv&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;[])&lt;/span&gt;
&lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;
&lt;span class=&quot;n&quot;&gt;MulleObjCDotdumpClass&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;&quot;MyClass&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;);&lt;/span&gt;
&lt;span class=&quot;k&quot;&gt;return&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;0&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;);&lt;/span&gt;
&lt;span class=&quot;p&quot;&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;
&lt;p&gt;Now build and run:&lt;/p&gt;
&lt;div class=&quot;language-console highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;go&quot;&gt;mulle-sde craft
mulle-sde run
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;
&lt;p&gt;Finally run the output &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;MyClass.dot&lt;/code&gt; through &lt;a href=&quot;https://graphviz.org/&quot;&gt;graphviz&lt;/a&gt;
to produce a graphics file:&lt;/p&gt;
&lt;div class=&quot;language-console highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;go&quot;&gt;dot -Tsvg -o MyClass.svg MyClass.dot
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;
</content>
</entry>
<entry>
<title type="html"><![CDATA[Quiz]]></title>
<link rel="alternate" type="text/html" href="https://www.mulle-kybernetik.com/quiz.html" />
<id>https://www.mulle-kybernetik.com/quiz.html</id>
<published>2024-11-29T00:00:00+01:00</published>
<updated>2024-11-29T00:00:00+01:00</updated>
<author>
<name>Nat!</name>
<uri>https://www.mulle-kybernetik.com</uri>
</author>
<content type="html">&lt;p&gt;Armed with this knowledge, here is an example project. Assume that
you are only linking against the &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;mulle-objc-runtime&lt;/code&gt;, which doesn’t provide
any classes.&lt;/p&gt;
&lt;div class=&quot;language-objc highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;k&quot;&gt;@interface&lt;/span&gt; &lt;span class=&quot;nc&quot;&gt;A&lt;/span&gt;
&lt;span class=&quot;k&quot;&gt;@property&lt;/span&gt; &lt;span class=&quot;kt&quot;&gt;char&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;*&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;x&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt;
&lt;span class=&quot;k&quot;&gt;+&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;instancetype&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;new&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt;
&lt;span class=&quot;k&quot;&gt;@end&lt;/span&gt;
&lt;span class=&quot;k&quot;&gt;@implementation&lt;/span&gt; &lt;span class=&quot;nc&quot;&gt;A&lt;/span&gt;
&lt;span class=&quot;k&quot;&gt;+&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;instancetype&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;new&lt;/span&gt;
&lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;
&lt;span class=&quot;k&quot;&gt;return&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;mulle_objc_infraclass_alloc_instance&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;self&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;));&lt;/span&gt;
&lt;span class=&quot;p&quot;&gt;}&lt;/span&gt;
&lt;span class=&quot;k&quot;&gt;-&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;kt&quot;&gt;char&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;*&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;x&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;{&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;return&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;kt&quot;&gt;char&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;*&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;__FUNCTION__&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;);&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;}&lt;/span&gt;
&lt;span class=&quot;k&quot;&gt;@end&lt;/span&gt;
&lt;span class=&quot;k&quot;&gt;@protocol&lt;/span&gt; &lt;span class=&quot;nc&quot;&gt;B&lt;/span&gt;
&lt;span class=&quot;k&quot;&gt;@optional&lt;/span&gt;
&lt;span class=&quot;k&quot;&gt;-&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;kt&quot;&gt;char&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;*&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;x&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt;
&lt;span class=&quot;k&quot;&gt;@end&lt;/span&gt;
&lt;span class=&quot;k&quot;&gt;@interface&lt;/span&gt; &lt;span class=&quot;nc&quot;&gt;B&lt;/span&gt;
&lt;span class=&quot;k&quot;&gt;-&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;kt&quot;&gt;char&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;*&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;x&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt;
&lt;span class=&quot;k&quot;&gt;@end&lt;/span&gt;
&lt;span class=&quot;k&quot;&gt;@implementation&lt;/span&gt; &lt;span class=&quot;nc&quot;&gt;B&lt;/span&gt;
&lt;span class=&quot;k&quot;&gt;-&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;kt&quot;&gt;char&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;*&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;x&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;{&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;return&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;kt&quot;&gt;char&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;*&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;__FUNCTION__&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;);&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;}&lt;/span&gt;
&lt;span class=&quot;k&quot;&gt;@end&lt;/span&gt;
&lt;span class=&quot;k&quot;&gt;@interface&lt;/span&gt; &lt;span class=&quot;nc&quot;&gt;C&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;nc&quot;&gt;A&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;&amp;lt;&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;B&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;&amp;gt;&lt;/span&gt;
&lt;span class=&quot;k&quot;&gt;@end&lt;/span&gt;
&lt;span class=&quot;k&quot;&gt;@implementation&lt;/span&gt; &lt;span class=&quot;nc&quot;&gt;C&lt;/span&gt;
&lt;span class=&quot;k&quot;&gt;@end&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;
&lt;div class=&quot;quiz_container&quot;&gt;
&lt;!-- Question 1 --&gt;
&lt;div class=&quot;quiz_question&quot;&gt;
&lt;p&gt;1. How many &lt;i&gt;metaclasses&lt;/i&gt; will exist at runtime ?&lt;/p&gt;
&lt;label class=&quot;quiz_label&quot;&gt;&lt;input type=&quot;radio&quot; name=&quot;q1&quot; value=&quot;wrong&quot; /&gt; none&lt;/label&gt;
&lt;label class=&quot;quiz_label&quot;&gt;&lt;input type=&quot;radio&quot; name=&quot;q1&quot; value=&quot;wrong&quot; /&gt; two&lt;/label&gt;
&lt;label class=&quot;quiz_label&quot;&gt;&lt;input type=&quot;radio&quot; name=&quot;q1&quot; value=&quot;right&quot; /&gt; three&lt;/label&gt;
&lt;label class=&quot;quiz_label&quot;&gt;&lt;input type=&quot;radio&quot; name=&quot;q1&quot; value=&quot;wrong&quot; /&gt; four&lt;/label&gt;
&lt;/div&gt;
&lt;!-- Question 2 --&gt;
&lt;div class=&quot;quiz_question&quot;&gt;
&lt;p&gt;2. How many &lt;i&gt;methods&lt;/i&gt; does &lt;i&gt;infraclass&lt;/i&gt; &lt;b&gt;C&lt;/b&gt; have in its &lt;i&gt;methodlists&lt;/i&gt; ?&lt;/p&gt;
&lt;label class=&quot;quiz_label&quot;&gt;&lt;input type=&quot;radio&quot; name=&quot;q2&quot; value=&quot;right&quot; /&gt; none&lt;/label&gt;
&lt;label class=&quot;quiz_label&quot;&gt;&lt;input type=&quot;radio&quot; name=&quot;q2&quot; value=&quot;wrong&quot; /&gt; one&lt;/label&gt;
&lt;label class=&quot;quiz_label&quot;&gt;&lt;input type=&quot;radio&quot; name=&quot;q2&quot; value=&quot;wrong&quot; /&gt; two&lt;/label&gt;
&lt;label class=&quot;quiz_label&quot;&gt;&lt;input type=&quot;radio&quot; name=&quot;q2&quot; value=&quot;wrong&quot; /&gt; &lt;b&gt;C&lt;/b&gt; has no methodlists&lt;/label&gt;
&lt;/div&gt;
&lt;!-- Question 3 --&gt;
&lt;div class=&quot;quiz_question&quot;&gt;
&lt;p&gt;3. What is the result of &lt;code&gt;[[C new] x]&lt;/code&gt; ?&lt;/p&gt;
&lt;label class=&quot;quiz_label&quot;&gt;&lt;input type=&quot;radio&quot; name=&quot;q3&quot; value=&quot;right&quot; /&gt; -[A x]&lt;/label&gt;
&lt;label class=&quot;quiz_label&quot;&gt;&lt;input type=&quot;radio&quot; name=&quot;q3&quot; value=&quot;wrong&quot; /&gt; -[B x]&lt;/label&gt;
&lt;label class=&quot;quiz_label&quot;&gt;&lt;input type=&quot;radio&quot; name=&quot;q3&quot; value=&quot;wrong&quot; /&gt; NULL&lt;/label&gt;
&lt;label class=&quot;quiz_label&quot;&gt;&lt;input type=&quot;radio&quot; name=&quot;q3&quot; value=&quot;wrong&quot; /&gt; a crash&lt;/label&gt;
&lt;/div&gt;
&lt;!-- Question 4 --&gt;
&lt;div class=&quot;quiz_question&quot;&gt;
&lt;p&gt;4. What is the result of &lt;code&gt;[C x]&lt;/code&gt; ?&lt;/p&gt;
&lt;label class=&quot;quiz_label&quot;&gt;&lt;input type=&quot;radio&quot; name=&quot;q4&quot; value=&quot;wrong&quot; /&gt; +[A x]&lt;/label&gt;
&lt;label class=&quot;quiz_label&quot;&gt;&lt;input type=&quot;radio&quot; name=&quot;q4&quot; value=&quot;right&quot; /&gt; -[A x]&lt;/label&gt;
&lt;label class=&quot;quiz_label&quot;&gt;&lt;input type=&quot;radio&quot; name=&quot;q4&quot; value=&quot;wrong&quot; /&gt; -[B x]&lt;/label&gt;
&lt;label class=&quot;quiz_label&quot;&gt;&lt;input type=&quot;radio&quot; name=&quot;q4&quot; value=&quot;wrong&quot; /&gt; a crash&lt;/label&gt;
&lt;/div&gt;
&lt;!-- Submit Button --&gt;
&lt;button class=&quot;quiz_button&quot; onclick=&quot;calculateScore()&quot;&gt;Submit Quiz&lt;/button&gt;
&lt;!-- Result --&gt;
&lt;div class=&quot;quiz_result&quot; id=&quot;quiz_result&quot;&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;script&gt;
function calculateScore() {
let score = 0;
let allAnswered = true;
const questions = [&quot;q1&quot;, &quot;q2&quot;, &quot;q3&quot;, &quot;q4&quot;];
questions.forEach((question) =&gt; {
const selectedAnswer = document.querySelector(`input[name=&quot;${question}&quot;]:checked`);
if (!selectedAnswer) {
allAnswered = false;
} else if (selectedAnswer.value === &quot;right&quot;) {
score++;
}
});
const resultDiv = document.getElementById(&quot;quiz_result&quot;);
// Array of messages for each possible score
const messages = [
&quot;Why don&apos;t you find yourself a nice scripting language ?&quot;,
&quot;Don&apos;t worry, there are other programming languages in the sea. Maybe rather checkout Go or Rust.&quot;,
&quot;Well the test is tricky, it can&apos;t hurt to peruse the pamphlet one more time.&quot;,
&quot;Almost there, but you had to guess at one time. And you chose poorly.&quot;,
&quot;Welcome to the Objective-C Pantheon!&quot;
];
// Check if all questions were answered
if (!allAnswered) {
resultDiv.textContent = &quot;Please answer all questions before submitting.&quot;;
} else {
// Display result with corresponding message
resultDiv.textContent = `${messages[score]}`;
}
}
document.querySelector(&apos;.quiz_button&apos;).addEventListener(&apos;click&apos;, function(e) {
this.classList.add(&apos;clicked&apos;);
setTimeout(() =&gt; this.classList.remove(&apos;clicked&apos;), 300);
});
&lt;/script&gt;
</content>
</entry>
<entry>
<title type="html"><![CDATA[Protocolclass]]></title>
<link rel="alternate" type="text/html" href="https://www.mulle-kybernetik.com/protocolclass.html" />
<id>https://www.mulle-kybernetik.com/protocolclass.html</id>
<published>2024-11-09T00:00:00+01:00</published>
<updated>2024-11-09T00:00:00+01:00</updated>
<author>
<name>Nat!</name>
<uri>https://www.mulle-kybernetik.com</uri>
</author>
<content type="html">&lt;h2 id=&quot;syntax-topic&quot;&gt;Syntax topic&lt;/h2&gt;
&lt;div class=&quot;language-objective-c highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;k&quot;&gt;@protocol&lt;/span&gt; &lt;span class=&quot;nc&quot;&gt;SomeProtocolClass&lt;/span&gt;
&lt;span class=&quot;k&quot;&gt;@end&lt;/span&gt;
&lt;span class=&quot;k&quot;&gt;@interface&lt;/span&gt; &lt;span class=&quot;nc&quot;&gt;SomeProtocolClass&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;SomeProtocolClass&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;&amp;gt;&lt;/span&gt;
&lt;span class=&quot;k&quot;&gt;@end&lt;/span&gt;
&lt;span class=&quot;k&quot;&gt;@interface&lt;/span&gt; &lt;span class=&quot;nc&quot;&gt;SomeClass&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;&amp;lt;&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;SomeProtocolClass&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;&amp;gt;&lt;/span&gt;
&lt;span class=&quot;k&quot;&gt;@end&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;
&lt;h2 id=&quot;protocolclass&quot;&gt;protocolclass&lt;/h2&gt;
&lt;p&gt;A &lt;strong&gt;protocolclass&lt;/strong&gt; is a &lt;em&gt;rootclass&lt;/em&gt; that implements a &lt;em&gt;protocol&lt;/em&gt; of the same
name. The methods declared as &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;@optional&lt;/code&gt; will be defined by the protocolclass,
for reuse by protocol adopting classes:&lt;/p&gt;
&lt;div class=&quot;language-objc highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;
&lt;span class=&quot;k&quot;&gt;@interface&lt;/span&gt; &lt;span class=&quot;nc&quot;&gt;RootClass&lt;/span&gt;
&lt;span class=&quot;k&quot;&gt;-&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;kt&quot;&gt;void&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;instanceMethod&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt;
&lt;span class=&quot;k&quot;&gt;@end&lt;/span&gt;
&lt;span class=&quot;k&quot;&gt;@implementation&lt;/span&gt; &lt;span class=&quot;nc&quot;&gt;RootClass&lt;/span&gt;
&lt;span class=&quot;k&quot;&gt;-&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;kt&quot;&gt;void&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;instanceMethod&lt;/span&gt;
&lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;
&lt;span class=&quot;n&quot;&gt;printf&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;&quot;%s&lt;/span&gt;&lt;span class=&quot;se&quot;&gt;\n&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;__FUNCTION__&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;);&lt;/span&gt;
&lt;span class=&quot;p&quot;&gt;}&lt;/span&gt;
&lt;span class=&quot;k&quot;&gt;@end&lt;/span&gt;
&lt;span class=&quot;k&quot;&gt;@protocol&lt;/span&gt; &lt;span class=&quot;nc&quot;&gt;ProtocolClass&lt;/span&gt;
&lt;span class=&quot;k&quot;&gt;@optional&lt;/span&gt;
&lt;span class=&quot;k&quot;&gt;-&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;kt&quot;&gt;void&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;instanceMethod&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt;
&lt;span class=&quot;k&quot;&gt;@end&lt;/span&gt;
&lt;span class=&quot;k&quot;&gt;@interface&lt;/span&gt; &lt;span class=&quot;nc&quot;&gt;ProtocolClass&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;&amp;lt;&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;ProtocolClass&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;&amp;gt;&lt;/span&gt;
&lt;span class=&quot;k&quot;&gt;@end&lt;/span&gt;
&lt;span class=&quot;k&quot;&gt;@implementation&lt;/span&gt; &lt;span class=&quot;nc&quot;&gt;ProtocolClass&lt;/span&gt;
&lt;span class=&quot;k&quot;&gt;-&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;kt&quot;&gt;void&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;instanceMethod&lt;/span&gt;
&lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;
&lt;span class=&quot;n&quot;&gt;IMP&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;imp&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt;
&lt;span class=&quot;n&quot;&gt;printf&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;&quot;%s&lt;/span&gt;&lt;span class=&quot;se&quot;&gt;\n&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;__FUNCTION__&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;);&lt;/span&gt;
&lt;span class=&quot;c1&quot;&gt;// can&apos;t call super&lt;/span&gt;
&lt;span class=&quot;n&quot;&gt;imp&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;MulleObjCOverriddenIMP&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt;
&lt;span class=&quot;k&quot;&gt;if&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;imp&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
&lt;span class=&quot;n&quot;&gt;MulleObjCIMPCall0&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;imp&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;self&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;_cmd&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;);&lt;/span&gt;
&lt;span class=&quot;p&quot;&gt;}&lt;/span&gt;
&lt;span class=&quot;k&quot;&gt;@end&lt;/span&gt;
&lt;span class=&quot;k&quot;&gt;@interface&lt;/span&gt; &lt;span class=&quot;nc&quot;&gt;SomeClass&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;nc&quot;&gt;RootClass&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;&amp;lt;&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;ProtocolClass&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;&amp;gt;&lt;/span&gt;
&lt;span class=&quot;k&quot;&gt;@end&lt;/span&gt;
&lt;span class=&quot;k&quot;&gt;@implementation&lt;/span&gt; &lt;span class=&quot;nc&quot;&gt;SomeClass&lt;/span&gt;
&lt;span class=&quot;k&quot;&gt;-&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;kt&quot;&gt;void&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;instanceMethod&lt;/span&gt;
&lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;
&lt;span class=&quot;n&quot;&gt;printf&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;&quot;%s&lt;/span&gt;&lt;span class=&quot;se&quot;&gt;\n&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;__FUNCTION__&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;);&lt;/span&gt;
&lt;span class=&quot;p&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;super&lt;/span&gt; &lt;span class=&quot;nf&quot;&gt;instanceMethod&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;];&lt;/span&gt;
&lt;span class=&quot;p&quot;&gt;}&lt;/span&gt;
&lt;span class=&quot;k&quot;&gt;@end&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;
&lt;p&gt;This turns out to be akin to multiple inheritance.&lt;/p&gt;
&lt;p&gt;&lt;img src=&quot;images/protocolclass.svg&quot; alt=&quot;protocolclass&quot; /&gt;&lt;/p&gt;
&lt;p&gt;When you run &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;[instance instanceMethod]&lt;/code&gt; the output will be:&lt;/p&gt;
&lt;div class=&quot;language-console highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;go&quot;&gt;-[SomeClass instanceMethod]
-[ProtocolClass instanceMethod]
-[RootClass instanceMethod]
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;
&lt;p&gt;The protocolclass “wedged” itself between the superclass and the adopting class.. The super call actually reached the protocolclass method, not the superclass
method.&lt;/p&gt;
&lt;p&gt;Interestingly, adding protocolclasses to a rootclass is
possible, but the compiler will not allow you to call super in the adopting
rootclass. A protocolclass will not want to call &lt;em&gt;super&lt;/em&gt; as it has no idea what the
superclass of the protocol adopting class is. Nevertheless, mulle-objc does not stand in
the way of a good hack, so you can reach the superclass method with
&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;MulleObjCOverriddenIMP&lt;/code&gt;, if so desired.&lt;/p&gt;
&lt;p&gt;What is obviously missing is the possibility to add instance variables.There are other solutions for this, but that is a topic for another pamphlet.&lt;/p&gt;
&lt;h3 id=&quot;the-order-of-protocolclasses-is-important&quot;&gt;The order of protocolclasses is important&lt;/h3&gt;
&lt;p&gt;Like the &lt;em&gt;methodlists&lt;/em&gt; of a class, the search order of protocolclasses is
back to front:&lt;/p&gt;
&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;@protocol A
@optional
- (void) instanceMethod;
@end
@interface A &amp;lt; A&amp;gt;
@end
@implementation A
- (void) instanceMethod
{
IMP imp;
printf( &quot;%s\n&quot;, __FUNCTION__);
imp = MulleObjCOverriddenIMP;
if( imp)
MulleObjCIMPCall0( imp, self, _cmd);
}
@end
@protocol B
@optional
- (void) instanceMethod;
@end
@interface B &amp;lt; B&amp;gt;
@end
@implementation B
- (void) instanceMethod
{
IMP imp;
printf( &quot;%s\n&quot;, __FUNCTION__);
imp = MulleObjCOverriddenIMP;
if( imp)
MulleObjCIMPCall0( imp, self, _cmd);
}
@end
@interface SomeClass &amp;lt; A, B&amp;gt;
@end
@implementation SomeClass
@end
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;
&lt;p&gt;This produces a class hierarchy:&lt;/p&gt;
&lt;p&gt;&lt;img src=&quot;images/protocolclass-order.svg&quot; alt=&quot;protocolclass&quot; /&gt;&lt;/p&gt;
&lt;p&gt;When you run &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;[obj instanceMethod]&lt;/code&gt; on a “SomeClass” instance, “B” will be
found first. So the output is:&lt;/p&gt;
&lt;div class=&quot;language-console highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;go&quot;&gt;-[B instanceMethod]
-[A instanceMethod]
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;
&lt;hr /&gt;
&lt;h2 id=&quot;api&quot;&gt;API&lt;/h2&gt;
&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Function/Name&lt;/th&gt;
&lt;th&gt;Description&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;_PROTOCOLCLASS_INTERFACE0&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Define protocol class without protocols&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;PROTOCOLCLASS_INTERFACE0&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Define protocol class with NSObject protocol&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;_PROTOCOLCLASS_INTERFACE&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Define protocol class with custom protocols&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;PROTOCOLCLASS_INTERFACE&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Define protocol class with NSObject and custom protocols&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;PROTOCOLCLASS_END&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;End protocol class definition&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;PROTOCOLCLASS_IMPLEMENTATION&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Begin protocol class implementation&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;MulleObjCOverriddenIMP&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Get overridden implementation in protocol class chain&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;MulleObjCClobberedIMP&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Get clobbered implementation (stops at class boundary)&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;
</content>
</entry>
<entry>
<title type="html"><![CDATA[Inheritance]]></title>
<link rel="alternate" type="text/html" href="https://www.mulle-kybernetik.com/inheritance.html" />
<id>https://www.mulle-kybernetik.com/inheritance.html</id>
<published>2024-11-08T00:00:00+01:00</published>
<updated>2024-11-08T00:00:00+01:00</updated>
<author>
<name>Nat!</name>
<uri>https://www.mulle-kybernetik.com</uri>
</author>
<content type="html">&lt;h2 id=&quot;syntax-topic&quot;&gt;Syntax topic&lt;/h2&gt;
&lt;div class=&quot;language-objective-c highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;k&quot;&gt;@interface&lt;/span&gt; &lt;span class=&quot;nc&quot;&gt;SomeClass&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;nc&quot;&gt;SomeSuperClass&lt;/span&gt;
&lt;span class=&quot;k&quot;&gt;@end&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;
&lt;h2 id=&quot;inheritance&quot;&gt;Inheritance&lt;/h2&gt;
&lt;p&gt;In terms of a C &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;struct&lt;/code&gt;, inheritance is akin to nesting a struct within another
struct:&lt;/p&gt;
&lt;div class=&quot;language-c highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;k&quot;&gt;struct&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;a&lt;/span&gt;
&lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;
&lt;span class=&quot;kt&quot;&gt;int&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;v&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt;
&lt;span class=&quot;p&quot;&gt;};&lt;/span&gt;
&lt;span class=&quot;k&quot;&gt;struct&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;b&lt;/span&gt;
&lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;
&lt;span class=&quot;k&quot;&gt;struct&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;a&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;a&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt;
&lt;span class=&quot;kt&quot;&gt;int&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;w&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt;
&lt;span class=&quot;p&quot;&gt;};&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;
&lt;p&gt;The Objective-C syntax &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;@interface &amp;lt;class&amp;gt; : &amp;lt;otherClass&amp;gt;&lt;/code&gt; is used
to define the inheritance:&lt;/p&gt;
&lt;div class=&quot;language-objc highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;k&quot;&gt;@interface&lt;/span&gt; &lt;span class=&quot;nc&quot;&gt;A&lt;/span&gt;
&lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;
&lt;span class=&quot;kt&quot;&gt;int&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;u&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt;
&lt;span class=&quot;kt&quot;&gt;int&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;v&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt;
&lt;span class=&quot;p&quot;&gt;}&lt;/span&gt;
&lt;span class=&quot;k&quot;&gt;-&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;kt&quot;&gt;int&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;getU&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt;
&lt;span class=&quot;k&quot;&gt;-&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;kt&quot;&gt;int&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;getV&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt;
&lt;span class=&quot;k&quot;&gt;@end&lt;/span&gt;
&lt;span class=&quot;k&quot;&gt;@implementation&lt;/span&gt; &lt;span class=&quot;nc&quot;&gt;A&lt;/span&gt;
&lt;span class=&quot;k&quot;&gt;-&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;kt&quot;&gt;int&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;getU&lt;/span&gt;
&lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;
&lt;span class=&quot;k&quot;&gt;return&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;u&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;);&lt;/span&gt;
&lt;span class=&quot;p&quot;&gt;}&lt;/span&gt;
&lt;span class=&quot;k&quot;&gt;-&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;kt&quot;&gt;int&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;getV&lt;/span&gt;
&lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;
&lt;span class=&quot;k&quot;&gt;return&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;v&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;);&lt;/span&gt;
&lt;span class=&quot;p&quot;&gt;}&lt;/span&gt;
&lt;span class=&quot;k&quot;&gt;@end&lt;/span&gt;
&lt;span class=&quot;k&quot;&gt;@interface&lt;/span&gt; &lt;span class=&quot;nc&quot;&gt;B&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;nc&quot;&gt;A&lt;/span&gt;
&lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;
&lt;span class=&quot;kt&quot;&gt;int&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;w&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt;
&lt;span class=&quot;p&quot;&gt;}&lt;/span&gt;
&lt;span class=&quot;k&quot;&gt;-&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;kt&quot;&gt;int&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;getW&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt;
&lt;span class=&quot;k&quot;&gt;@end&lt;/span&gt;
&lt;span class=&quot;k&quot;&gt;@implementation&lt;/span&gt; &lt;span class=&quot;nc&quot;&gt;B&lt;/span&gt;
&lt;span class=&quot;k&quot;&gt;-&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;kt&quot;&gt;int&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;getV&lt;/span&gt;
&lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;
&lt;span class=&quot;k&quot;&gt;return&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;super&lt;/span&gt; &lt;span class=&quot;nf&quot;&gt;getU&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;]&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;+&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;super&lt;/span&gt; &lt;span class=&quot;nf&quot;&gt;getV&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;]);&lt;/span&gt;
&lt;span class=&quot;p&quot;&gt;}&lt;/span&gt;
&lt;span class=&quot;k&quot;&gt;-&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;kt&quot;&gt;int&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;getW&lt;/span&gt;
&lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;
&lt;span class=&quot;k&quot;&gt;return&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;w&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;);&lt;/span&gt;
&lt;span class=&quot;p&quot;&gt;}&lt;/span&gt;
&lt;span class=&quot;k&quot;&gt;@end&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;
&lt;p&gt;The runtime will now look like this:&lt;/p&gt;
&lt;p&gt;&lt;img src=&quot;images/inheritance.svg&quot; alt=&quot;Inheritance&quot; /&gt;There is a uni-directional relationship &lt;strong&gt;super&lt;/strong&gt; between the class B and its &lt;strong&gt;superclass&lt;/strong&gt; A..&lt;/p&gt;
&lt;p&gt;The instance variables and methods of class A are &lt;em&gt;inherited&lt;/em&gt; by B.As you can see, the contents of the ivarlists and methodlists of A are not copied down to B.Nevertheless, all methods and instance variables of A are now available in B.&lt;/p&gt;
&lt;h3 id=&quot;super&quot;&gt;super&lt;/h3&gt;
&lt;p&gt;With the special &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;[super method]&lt;/code&gt; syntax, a method of a superclass can be
invoked, even if there is a method with the same name in the current class.&lt;/p&gt;
&lt;h3 id=&quot;special-case-the-root-class&quot;&gt;Special case: the root class&lt;/h3&gt;
&lt;p&gt;A root class is a class that does not have a superclass. There is a special
treatment for ‘+’ class methods on these root classes.&lt;/p&gt;
&lt;div class=&quot;language-objc highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;k&quot;&gt;@interface&lt;/span&gt; &lt;span class=&quot;nc&quot;&gt;RootClass&lt;/span&gt;
&lt;span class=&quot;k&quot;&gt;+&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;kt&quot;&gt;void&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;classMethod&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt;
&lt;span class=&quot;k&quot;&gt;-&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;kt&quot;&gt;void&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;instanceMethod&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt;
&lt;span class=&quot;k&quot;&gt;@end&lt;/span&gt;
&lt;span class=&quot;k&quot;&gt;@implementation&lt;/span&gt; &lt;span class=&quot;nc&quot;&gt;RootClass&lt;/span&gt;
&lt;span class=&quot;k&quot;&gt;+&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;kt&quot;&gt;void&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;classMethod&lt;/span&gt;
&lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;
&lt;span class=&quot;n&quot;&gt;printf&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;&quot;%s&lt;/span&gt;&lt;span class=&quot;se&quot;&gt;\n&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;__FUNCTION__&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;);&lt;/span&gt;
&lt;span class=&quot;p&quot;&gt;}&lt;/span&gt;
&lt;span class=&quot;k&quot;&gt;-&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;kt&quot;&gt;void&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;instanceMethod&lt;/span&gt;
&lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;
&lt;span class=&quot;n&quot;&gt;printf&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;&quot;%s&lt;/span&gt;&lt;span class=&quot;se&quot;&gt;\n&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;__FUNCTION__&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;);&lt;/span&gt;
&lt;span class=&quot;p&quot;&gt;}&lt;/span&gt;
&lt;span class=&quot;k&quot;&gt;@end&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;
&lt;p&gt;When you run&lt;/p&gt;
&lt;div class=&quot;language-objc highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;p&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;cls&lt;/span&gt; &lt;span class=&quot;nf&quot;&gt;classMethod&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;];&lt;/span&gt;
&lt;span class=&quot;p&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;cls&lt;/span&gt; &lt;span class=&quot;nf&quot;&gt;instanceMethod&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;];&lt;/span&gt;
&lt;span class=&quot;p&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;instance&lt;/span&gt; &lt;span class=&quot;nf&quot;&gt;instanceMethod&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;];&lt;/span&gt;
&lt;span class=&quot;p&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;instance&lt;/span&gt; &lt;span class=&quot;nf&quot;&gt;classMethod&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;];&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;
&lt;p&gt;the output will be:&lt;/p&gt;
&lt;div class=&quot;language-console highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;go&quot;&gt;+[RootClass classMethod]
-[RootClass instanceMethod]
-[RootClass instanceMethod]
mulle_objc_universe 0x5B74C1D11080 fatal: unknown method c3074566 &quot;-classMethod&quot; in class 4b9217f9 &quot;RootClass&quot;
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;
&lt;p&gt;So what is going on here?&lt;/p&gt;
&lt;p&gt;&lt;img src=&quot;images/RootClass.svg&quot; alt=&quot;Root class&quot; /&gt;&lt;/p&gt;
&lt;p&gt;If you follow the &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;isa/meta&lt;/code&gt; path, you will see that the metaclass of the
metaclass as actually the infraclass again. So a rootclass class methods
are augmented with the infraclass methods.&lt;/p&gt;
&lt;p&gt;This is something to be aware of. So root classes usually have
a class method implementation for every instance method to avoid surprises.
Another option is to put a empty root class on top.&lt;/p&gt;
&lt;hr /&gt;
&lt;h2 id=&quot;api&quot;&gt;API&lt;/h2&gt;
&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Function/Method Name&lt;/th&gt;
&lt;th&gt;Description&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;-superclass&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Get receiver’s superclass&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;+superclass&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Get class’s superclass&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;+isSubclassOfClass:&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Check if class inherits from given class&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;-isKindOfClass:&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Check if receiver inherits from or is instance of class&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;-isMemberOfClass:&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Check if receiver is direct instance of class&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;[super ...]&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Language feature to call superclass implementation&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;MulleObjCClassIsSubclassOfClass&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;C function to check class inheritance relationship&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;NSObjectIsKindOfClass&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;C function for instance/class relationship check&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;MulleObjCInstanceIsMemberOfClass&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;C function for direct instance/class check&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;MulleObjCSuperIMP&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Get superclass implementation of current method&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;
</content>
</entry>
<entry>
<title type="html"><![CDATA[Protocol]]></title>
<link rel="alternate" type="text/html" href="https://www.mulle-kybernetik.com/protocol.html" />
<id>https://www.mulle-kybernetik.com/protocol.html</id>
<published>2024-11-07T00:00:00+01:00</published>
<updated>2024-11-07T00:00:00+01:00</updated>
<author>
<name>Nat!</name>
<uri>https://www.mulle-kybernetik.com</uri>
</author>
<content type="html">&lt;h2 id=&quot;syntax-topics&quot;&gt;Syntax topics&lt;/h2&gt;
&lt;div class=&quot;language-objective-c highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;k&quot;&gt;@protocol&lt;/span&gt; &lt;span class=&quot;nc&quot;&gt;SomeProtocol&lt;/span&gt;
&lt;span class=&quot;k&quot;&gt;@end&lt;/span&gt;
&lt;span class=&quot;k&quot;&gt;@interface&lt;/span&gt; &lt;span class=&quot;nc&quot;&gt;SomeClass&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;SomeProtocol&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;&amp;gt;&lt;/span&gt;
&lt;span class=&quot;k&quot;&gt;@end&lt;/span&gt;
&lt;span class=&quot;p&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;objc&lt;/span&gt; &lt;span class=&quot;nf&quot;&gt;conformsToProtocol&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;@protocol&lt;/span&gt;&lt;span class=&quot;err&quot;&gt;(&lt;/span&gt; &lt;span class=&quot;nc&quot;&gt;SomeProtocol&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)];&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;
&lt;h2 id=&quot;protocol&quot;&gt;@protocol&lt;/h2&gt;
&lt;p&gt;A &lt;strong&gt;protocol&lt;/strong&gt; is a way to declare a set of methods. A class that
&lt;em&gt;adopts&lt;/em&gt; a protocol, declares that it implements all of the methods in the
protocol:&lt;/p&gt;
&lt;div class=&quot;language-objc highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;k&quot;&gt;@protocol&lt;/span&gt; &lt;span class=&quot;nc&quot;&gt;EmptyProtocol&lt;/span&gt;
&lt;span class=&quot;k&quot;&gt;@end&lt;/span&gt;
&lt;span class=&quot;k&quot;&gt;@interface&lt;/span&gt; &lt;span class=&quot;nc&quot;&gt;SomeClass&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;EmptyProtocol&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;&amp;gt;&lt;/span&gt;
&lt;span class=&quot;k&quot;&gt;@end&lt;/span&gt;
&lt;span class=&quot;k&quot;&gt;@implementation&lt;/span&gt; &lt;span class=&quot;nc&quot;&gt;SomeClass&lt;/span&gt;
&lt;span class=&quot;c1&quot;&gt;// protocol EmptyProtocol is empty, so no need to implement anything&lt;/span&gt;
&lt;span class=&quot;k&quot;&gt;@end&lt;/span&gt;