Skip to content

aspect_cleanupHookedClassAndSelector recover the class when it has another selector hack. #91

@l1002k

Description

@l1002k
// 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.....

Activity

added a commit that references this issue on Jun 6, 2016
hovox

hovox commented on Mar 3, 2017

@hovox

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

      Development

      No branches or pull requests

        Participants

        @hovox@l1002k

        Issue actions

          aspect_cleanupHookedClassAndSelector recover the class when it has another selector hack. · Issue #91 · steipete/Aspects