YYModel
YYModel copied to clipboard
crash 在YYClassMethodInfo initWithMethod方法
`- (instancetype)initWithMethod:(Method)method {
if (!method) return nil;
self = [super init];
_method = method;
_sel = method_getName(method);
_imp = method_getImplementation(method);
const char *name = sel_getName(_sel);
if (name) {
_name = [NSString stringWithUTF8String:name];
}
const char *typeEncoding = method_getTypeEncoding(method);
if (typeEncoding) {
_typeEncoding = [NSString stringWithUTF8String:typeEncoding];
}
char *returnType = method_copyReturnType(method);
if (returnType) {
_returnTypeEncoding = [NSString stringWithUTF8String:returnType];
free(returnType);
}
unsigned int argumentCount = method_getNumberOfArguments(method);
if (argumentCount > 0) {
NSMutableArray *argumentTypes = [NSMutableArray new];
for (unsigned int i = 0; i < argumentCount; i++) {
char *argumentType = method_copyArgumentType(method, i);
NSString *type = argumentType ? [NSString stringWithUTF8String:argumentType] : nil;
[argumentTypes addObject:type ? type : @""];
if (argumentType) free(argumentType);
}
_argumentTypeEncodings = argumentTypes;
}
return self;
}`
crash在stringWithUTF8String上,感觉在for循环里的
char *argumentType = method_copyArgumentType(method, i); NSString *type = argumentType ? [NSString stringWithUTF8String:argumentType] : nil;
两句,stringWithUTF8String 方法使用里写了Raises an exception if bytes is NULL,但代码里看着做了判断,所以暂时先放在这、
同样crash在这里, 在大项目中混用swift的时候, 会段在
// YYClassMethodInfo.m
- (instancetype)initWithMethod:(Method)method {
unsigned int argumentCount = method_getNumberOfArguments(method); }
不知道是为什么, 所以我直接返回了.
这个问题还会修复吗,或者作者给个解决思路?
@iOSleep +1
description对象的属性为Dictionary时crash
description对象的属性为Dictionary时crash +1
遇到同样的crash,请问这个问题现在修复了吗?
+1 避免使用 yy_modelDescription 方法