在项目中同时使用Objective-C和Swift
在项目中同时使用Objective-C和Swift
苹果发布的Swift语言可以和之前的Objective-C语言同时存在于一个项目中。
可能有人会认为是同一个类文件中既可以有Objective-C也可以有Swift,这是不对的。同一个类文件或同一个代码块中,不可以同时有这两个语言的代码,而是单独的Swift类文件或Objective-C类文件之间可以相互调用。
接下来就说说在Objective-C类中如何引用swift类和在Swift类中引用Objective-C类的具体步骤。
在Swift中使用Objective-C
首先创建一个Swift的iOS项目:
富婆男人 http://c.tieba.baidu.com/p/3416154550
http://c.tieba.baidu.com/p/3416214691
http://c.tieba.baidu.com/p/3416216356
http://c.tieba.baidu.com/p/3416218526
http://c.tieba.baidu.com/p/3416242623
http://c.tieba.baidu.com/p/3416236901
http://c.tieba.baidu.com/p/3416244442
http://c.tieba.baidu.com/p/3416246899
http://c.tieba.baidu.com/p/3416250221
http://c.tieba.baidu.com/p/3416250987
http://c.tieba.baidu.com/p/3416251778
http://c.tieba.baidu.com/p/3416252537
http://c.tieba.baidu.com/p/3416254165
http://c.tieba.baidu.com/p/3416259628
http://c.tieba.baidu.com/p/3416265157
http://c.tieba.baidu.com/p/3416265663
http://c.tieba.baidu.com/p/3416267851
http://c.tieba.baidu.com/p/3416265663
http://c.tieba.baidu.com/p/3416271970
http://c.tieba.baidu.com/p/3416272953
http://c.tieba.baidu.com/p/3416274249
http://c.tieba.baidu.com/p/3416264185
http://c.tieba.baidu.com/p/3416276815
http://c.tieba.baidu.com/p/3416277667
http://c.tieba.baidu.com/p/3416277992
http://c.tieba.baidu.com/p/3416278500
http://c.tieba.baidu.com/p/3416277992
http://c.tieba.baidu.com/p/3416279403
http://c.tieba.baidu.com/p/3416281924
http://c.tieba.baidu.com/p/3416251778
http://c.tieba.baidu.com/p/3416282333
http://c.tieba.baidu.com/p/3416282333
http://c.tieba.baidu.com/p/3416283767
http://c.tieba.baidu.com/p/3416284628
http://c.tieba.baidu.com/p/3416285429
http://c.tieba.baidu.com/p/3416286247
http://c.tieba.baidu.com/p/3416286855
http://c.tieba.baidu.com/p/3416287526
http://c.tieba.baidu.com/p/3416288231
http://c.tieba.baidu.com/p/3416288950
http://c.tieba.baidu.com/p/3416289659
http://c.tieba.baidu.com/p/3416290412
http://c.tieba.baidu.com/p/3416291201
http://c.tieba.baidu.com/p/3416292026
http://c.tieba.baidu.com/p/3416292958
http://c.tieba.baidu.com/p/3416293957
http://c.tieba.baidu.com/p/3416294958
http://c.tieba.baidu.com/p/3416295987
http://c.tieba.baidu.com/p/3416297139
http://c.tieba.baidu.com/p/3416298364
http://c.tieba.baidu.com/p/3416299573
http://c.tieba.baidu.com/p/3416300813
http://c.tieba.baidu.com/p/3416302224
http://c.tieba.baidu.com/p/3416303106
http://c.tieba.baidu.com/p/3416306602
http://c.tieba.baidu.com/p/3416318208
http://c.tieba.baidu.com/p/3416349385
http://c.tieba.baidu.com/p/3416358223
http://c.tieba.baidu.com/p/3416362223
http://c.tieba.baidu.com/p/3416312482
http://c.tieba.baidu.com/p/3416371522
http://c.tieba.baidu.com/p/3416375650
http://c.tieba.baidu.com/p/3416386347
http://c.tieba.baidu.com/p/3416382209
http://c.tieba.baidu.com/p/3416406284
http://c.tieba.baidu.com/p/3416479297
http://c.tieba.baidu.com/p/3416491757
http://c.tieba.baidu.com/p/3416497177
http://c.tieba.baidu.com/p/3416506256
http://c.tieba.baidu.com/p/3416510186
http://c.tieba.baidu.com/p/3416523057
http://c.tieba.baidu.com/p/3416529958
http://c.tieba.baidu.com/p/3416538339
http://c.tieba.baidu.com/p/3416549272
http://c.tieba.baidu.com/p/3416556218
http://c.tieba.baidu.com/p/3416561418
http://c.tieba.baidu.com/p/3416565907
http://c.tieba.baidu.com/p/3416570804
http://c.tieba.baidu.com/p/3416604697
http://c.tieba.baidu.com/p/3416610864
http://c.tieba.baidu.com/p/3416616621
http://c.tieba.baidu.com/p/3416648039
http://c.tieba.baidu.com/p/3416655761
http://c.tieba.baidu.com/p/3416663363
http://c.tieba.baidu.com/p/3416670306
http://c.tieba.baidu.com/p/3416674665
http://c.tieba.baidu.com/p/3416681841
http://c.tieba.baidu.com/p/3416685867
http://c.tieba.baidu.com/p/3416691025
http://c.tieba.baidu.com/p/3416697502
http://c.tieba.baidu.com/p/3416703397
http://c.tieba.baidu.com/p/3416714370
http://c.tieba.baidu.com/p/3416718705
http://c.tieba.baidu.com/p/3416724151
http://c.tieba.baidu.com/p/3416729244
http://c.tieba.baidu.com/p/3416924505
http://c.tieba.baidu.com/p/3416931786
http://c.tieba.baidu.com/p/3416942542
http://c.tieba.baidu.com/p/3416946306
http://c.tieba.baidu.com/p/3416951539
http://c.tieba.baidu.com/p/3416959064
http://c.tieba.baidu.com/p/3416965148
http://c.tieba.baidu.com/p/3380070384
http://c.tieba.baidu.com/p/3417009705
http://c.tieba.baidu.com/p/3417003661
http://c.tieba.baidu.com/p/3416997853
http://c.tieba.baidu.com/p/3417009705
http://c.tieba.baidu.com/p/3417032797
http://c.tieba.baidu.com/p/3417040592
http://c.tieba.baidu.com/p/3380128613
http://c.tieba.baidu.com/p/3380124047
http://c.tieba.baidu.com/p/3417044850
http://c.tieba.baidu.com/p/3380119414
http://c.tieba.baidu.com/p/3416946306
http://c.tieba.baidu.com/p/3417048997
http://c.tieba.baidu.com/p/3417055495
http://c.tieba.baidu.com/p/3417062022
http://c.tieba.baidu.com/p/3380200259
http://c.tieba.baidu.com/p/3417077153
http://c.tieba.baidu.com/p/3417085287
http://c.tieba.baidu.com/p/3417092739
http://c.tieba.baidu.com/p/3417122597
http://c.tieba.baidu.com/p/3417132031
http://c.tieba.baidu.com/p/3417136532
http://c.tieba.baidu.com/p/3417136532
http://c.tieba.baidu.com/p/3417127954
http://c.tieba.baidu.com/p/3417122597
http://c.tieba.baidu.com/p/3417149103
http://c.tieba.baidu.com/p/3417144915
http://c.tieba.baidu.com/p/3417158311
http://c.tieba.baidu.com/p/3417167807
http://c.tieba.baidu.com/p/3417178110
http://c.tieba.baidu.com/p/3417195262
http://c.tieba.baidu.com/p/3381926766
http://c.tieba.baidu.com/p/3417216604
http://c.tieba.baidu.com/p/3417221477
http://c.tieba.baidu.com/p/3417225995
http://c.tieba.baidu.com/p/3417233658
http://c.tieba.baidu.com/p/3417238116
http://c.tieba.baidu.com/p/3417252336
http://c.tieba.baidu.com/p/3417242306
http://c.tieba.baidu.com/p/3417263886
http://c.tieba.baidu.com/p/3417307988
http://c.tieba.baidu.com/p/3417280392
http://c.tieba.baidu.com/p/3417283787
http://c.tieba.baidu.com/p/3417287635
http://c.tieba.baidu.com/p/3417295269
http://c.tieba.baidu.com/p/3417298507
http://c.tieba.baidu.com/p/3417302880
http://c.tieba.baidu.com/p/3417324172
http://c.tieba.baidu.com/p/3417327905
http://c.tieba.baidu.com/p/3417334222
郑重声明:本站内容如果来自互联网及其他传播媒体,其版权均属原媒体及文章作者所有。转载目的在于传递更多信息及用于网络分享,并不代表本站赞同其观点和对其真实性负责,也不构成任何其他建议。