TPMultiLayoutViewController的ARC转换; 使用ARC不允许将Objective-C指针隐式转换为'const void*'

akb*_*eam 1 objective-c ios automatic-ref-counting

我正在尝试在使用ARC的项目中使用TPMultiLayoutViewController,但是碰到了以下错误: -

使用ARC不允许将Objective-C指针隐式转换为'const void*'

我真的不确定如何解决这个问题; 它需要明确转换吗?我该怎么做?

- (void)addAttributesForSubviewHierarchy:(UIView*)view associatedWithSubviewHierarchy:(UIView*)associatedView toTable:(NSMutableDictionary*)table {
    [table setObject:[self attributesForView:view] forKey:[NSValue valueWithPointer:associatedView]];

    if ( ![self shouldDescendIntoSubviewsOfView:view] ) return;

    for ( UIView *subview in view.subviews ) {
        UIView *associatedSubView = (view == associatedView ? subview : [self findAssociatedViewForView:subview amongViews:associatedView.subviews]);
        if ( associatedSubView ) {
            [self addAttributesForSubviewHierarchy:subview associatedWithSubviewHierarchy:associatedSubView toTable:table];
        }
    }
}
Run Code Online (Sandbox Code Playgroud)

Wev*_*vah 5

你因此得到错误:

[NSValue valueWithPointer:associatedView]
Run Code Online (Sandbox Code Playgroud)

自从valueWithPointer:拿了一个const char *.您可以通过执行@ user1139069建议的操作来解决此问题:

[NSValue valueWithPointer:(__bridge void *)associatedView]
Run Code Online (Sandbox Code Playgroud)