以MBProgressHUD为例子
swift中Podfile文件一般都会加上use_frameworks! 这样就可以直接通过import MBProgressHUD来访问MBProgressHUD中的方法了
这个时候如果我们想要给MBProgressHUD添加一些方法,一般会使用category,在创建category的时候#import "MBProgressHUD.h"
提示无法找到对应的头文件
导致这个问题的原因是use_frameworks!会把我们导入的第三方库转换成framework
swift中访问framework的方法:
import MBProgressHUD
Objective-C中访问framework的方法:
@import MBProgressHUD;
同样的道理,如果我们想在swift中使用AFNetWorking,然后又想给AF初始化一些参数,可以使用@import AFNetworking; 附AFNetworking中利用runtime动态acceptableContentTypes的方法
@implementation AFJSONResponseSerializer (Serializer)
+(void)load {
static dispatch_once_t onceToken;
dispatch_once(&onceToken, ^{
Method ovr_initMethod = class_getInstanceMethod([self class], @selector(init));
Me