moaible / MOAspects

AOP Library for iOS
MIT License
163 stars 25 forks source link

Crash at stringWithClass #24

Open Damonvvong opened 6 years ago

Damonvvong commented 6 years ago

I have got a crash at

0   MOAspects                       0x0000000103721824 +[MOARuntime stringWithClass:] + 22564 (MOARuntime.m:43)
1   MOAspects                       0x0000000103723d28 +[MOAspectsStore keyWithClass:selector:methodType:] + 32040 (MOAspectsStore.m:48)
2   MOAspects                       0x0000000103723860 +[MOAspects targetInStoreWithClass:selector:methodType:hookRange:] + 30816 (MOAspects.m:290)
3   MOAspects                       0x0000000103722884 +[MOAspects hookMethodForClass:selector:methodType:aspectsPosition:hookRange:usingBlock:] + 26756 (MOAspects.m:107)
4   MOAspects                       0x00000001037226e0 +[MOAspects hookInstanceMethodForClass:selector:aspectsPosition:hookRange:usingBlock:] + 26336 (MOAspects.m:46)
5   MOAspects                       0x0000000103722548 +[MOAspects(Swift) hookInstanceMethodForClass:selector:position:range:usingParameterBlock0:] + 25928 (MOAspects+Swift.m:28)

here is your code

// MOARuntime.m line 43
+ (NSString *)stringWithClass:(Class)clazz
{
    return [NSString stringWithCString:object_getClassName(clazz)
                              encoding:NSUTF8StringEncoding];
}

here is similar problems

So, Whether to change into the following will be better

+ (NSString *)stringWithClass:(Class)clazz
{
    return NSStringFromClass(clazz);
}