1 Star 0 Fork 0

宝东/iOS_RunTime

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
NSMutableDictionary+RunTime.m 1.65 KB
一键复制 编辑 原始数据 按行查看 历史
//
// NSMutableDictionary+RunTime.m
// EDCsfzs
//
// Created by feng on 16/9/26.
// Copyright © 2016年 冯宝东. All rights reserved.
//
#import "NSMutableDictionary+RunTime.h"
#import "FBDSwizzingTool.h"
#import <Foundation/NSObject.h>
@implementation NSMutableDictionary (RunTime)
+(void)load
{
static dispatch_once_t onceToken;
dispatch_once(&onceToken, ^{
Class class = NSClassFromString(@"__NSDictionaryM");
[FBDSwizzingTool fbdSwizzingClass:class OriginSelectName:@"setObject:forKey:" overName:@"fbd_setObject:forKey:"];
});
// Class class=NSClassFromString(@"__NSDictionaryM");
// SEL originSEL= NSSelectorFromString(@"setObject:forKey:");
// SEL overSEL= NSSelectorFromString(@"fbd_setObject:forKey:");
// Method originM= class_getInstanceMethod(class, originSEL);
// Method overM=class_getInstanceMethod(class, overSEL);
// BOOL didAddM=class_addMethod(class, originSEL, method_getImplementation(overM), method_getTypeEncoding(overM));
// if (didAddM)
// {
// class_replaceMethod(class, overSEL, method_getImplementation(originM), method_getTypeEncoding(originM));
// }else
// {
// method_exchangeImplementations(originM, overM);
//
// }
}
-(void)test:(NSString*)objValue
{
[self setObject:@"wq" forKey:@"11"];
}
-(void)fbd_setObject:(id)anObject forKey:(id<NSCopying>)aKey
{
if (!anObject||[anObject isEqual:[NSNull null]]) {
NSLog(@"fbd_setObject 为 null 或者为 nil");
[self fbd_setObject:@"fit_null" forKey:aKey];
return;
}
if (!aKey) {
return;
}
[self fbd_setObject:anObject forKey:aKey];
}
@end
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/donggehaoya/iOS_RunTime.git
git@gitee.com:donggehaoya/iOS_RunTime.git
donggehaoya
iOS_RunTime
iOS_RunTime
master

搜索帮助

0d507c66 1850385 C8b1a773 1850385