iOS

前言

  • 在 Objective-C 语言中,我们可以使用 C、Swift 语言编写代码,我们可以导入任意用 C、Swift 写的 Cocoa 平台框架、C 框架或 Swift 类库。

1、在 C 中使用 Objective-C 代码

1.1 在 Objective-C 项目中的 C 函数中使用 Objective-C 代码

  • 1> 在 .m 文件中定义函数指针。

    	static ViewController *selfClass = nil;
    	
    	// 函数指针指向本身
    	selfClass = self;
    
  • 2> 在 C 函数中使用定义的函数指针调用 OC 的方法。

    	[selfClass showMessage:@"hello word"];
    
原文地址:https://www.cnblogs.com/QianChia/p/6396035.html