swift与OC混编
swift是一门强语言,而OC是一门弱语言。强语言比弱语言更加严谨 每写一行代码系统都会自动检测是否有错误,这样就减少了运行后出错的可能。swift支持开源,OC是闭源,在用OC开发中一些封装控件可能没有OC版本 这时候我们可以利用swift语言嵌套进入,进行swift和OC的混编。

2、创建header文件,这个我理解是SWift是没有.h文件的 ,创建这个作为混编的桥接的文件


Swift调用OC方法--------在桥接文件中引入OC 头文件

OC中的方法如下

下面是Swift调用OC方法的使用
import UIKit
class SwiftView: UIView {
//Swift调用OC方法
let lableTest = Tool.creatLableAttribute(14.0, fontName:"hhaha", color:"ffffff")
OC调用Swift方法
1、Swift方法
func viewOne(frame:CGRect,color:UIColor) -> UIView {
let viewTest = UIView()
viewTest.frame = frame
viewTest.backgroundColor = color
return viewTest
}
首先在OC要调用的swift方法的文件中 引用(#import "工程名-Swift.h")eg:#import "OC与Swift混编-Swift.h"
//OC调用Swift
SwiftView *view1 = [[SwiftView alloc] init];
UIView *view2 = [view1 viewOneWithFrame:CGRectMake(100, 100, 60, 60) color:[UIColor redColor]];
[self.view addSubview:view2];