更新iOS13后跳转Storyboard页面崩溃问题记录

场景还原:12升13后意外的发现点击SB创建的VC后出现崩溃问题,通过下面的报错信息实在是看不出问题出现在哪里.iOS12确实是没问题的,估计苹果可能改变了nib加载的方式.
崩溃信息:

-[UIProxyObject containsNibNamed:]: unrecognized selector sent to instance 0x6000002680c0'

原因:因为项目里面队友添加了一个防止NSDictionary赋值崩溃的分类如下

+ (void)load {
    [super load];
    static dispatch_once_t onceToken;
    dispatch_once(&onceToken, ^{
        Method fromMethod = class_getInstanceMethod(objc_getClass("__NSDictionaryM"), @selector(setObject:forKey:));
        Method toMethod = class_getInstanceMethod(objc_getClass("__NSDictionaryM"), @selector(em_setObject:forKey:));
        method_exchangeImplementations(fromMethod, toMethod);
    });
}

- (void)em_setObject:(id)emObject forKey:(NSString *)key {
    if (emObject && key) {
        [self em_setObject:emObject forKey:key];
    }
}

+ (instancetype)dictionaryWithObject:(id)object forKey:(id)key{
    NSMutableDictionary *dic = [super dictionary];
    if (key && object) {
        return dic;
    }
    return dic;
}

你可能感兴趣的:(更新iOS13后跳转Storyboard页面崩溃问题记录)