Aspects icon indicating copy to clipboard operation
Aspects copied to clipboard

aspect_cleanupHookedClassAndSelector recover the class when it has another selector hack.

Open l1002k opened this issue 9 years ago • 1 comments

// Get the aspect container and check if there are any hooks remaining. Clean up if there are not.
    AspectsContainer *container = aspect_getContainerForObject(self, selector);
    if (!container.hasAspects) {
        // Destroy the container
        aspect_destroyContainerForObject(self, selector);

        // Figure out how the class was modified to undo the changes.
        NSString *className = NSStringFromClass(klass);
        if ([className hasSuffix:AspectsSubclassSuffix]) {
            Class originalClass = NSClassFromString([className stringByReplacingOccurrencesOfString:AspectsSubclassSuffix withString:@""]);
            NSCAssert(originalClass != nil, @"Original class must exist");
            object_setClass(self, originalClass);
            AspectLog(@"Aspects: %@ has been restored.", NSStringFromClass(originalClass));

it recover the class, but it has another selector hack.....

l1002k avatar Jun 03 '16 03:06 l1002k

Shouldn't this be merged into master ? it's fixed bad_access crash for us. Crash happened because we have added/removed some method swizzling on the same class from different places.

hovox avatar Mar 03 '17 13:03 hovox