简体   繁体   English

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

[英]ARC conversion of TPMultiLayoutViewController; Implicit conversion of an Objective-C pointer to 'const void *' is disallowed with ARC

I'm trying to use TPMultiLayoutViewController in a project using ARC, but am bumping into the following error:- 我正在尝试在使用ARC的项目中使用TPMultiLayoutViewController ,但遇到以下错误:-

Implicit conversion of an Objective-C pointer to 'const void *' is disallowed with ARC ARC不允许将Objective-C指针隐式转换为“ const void *”

I'm really not sure how to tackle this; 我真的不确定如何解决这个问题。 does it need explicitly converting? 需要显式转换吗? and how would I do that? 我该怎么办?

- (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];
        }
    }
}

You're getting the error because of this: 由于以下原因,您遇到了错误:

[NSValue valueWithPointer:associatedView]

Since valueWithPointer: takes a const char * . 由于valueWithPointer:需要const char * You can work around this by doing what @ user1139069 suggested: 您可以通过执行@ user1139069建议的方法来解决此问题:

[NSValue valueWithPointer:(__bridge void *)associatedView]

如果您使用[NSValue valueWithNonretainedObject:]而不是[NSValue valueWithPointer:]怎么办?

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 ARC不允许将Objective-C指针隐式转换为'const char *'? - Implicit conversion of an Objective-C pointer to 'const char *' is disallowed with ARC? ARC 不允许将 Objective-C 指针隐式转换为“void *” - implicit conversion of an Objective-C pointer to 'void *' is disallowed with ARC 从Objective-C指针到int *的隐式转换不允许使用ARC - Implicit Conversion from Objective-C Pointer to int * is Disallowed With ARC ARC不允许对Objective-C指针进行隐式转换 - Implicit conversion of an Objective-C pointer is disallowed with ARC 使用ARC-sqlite3不允许将Objective-C指针隐式转换为'void *' - implicit conversion of an Objective-C pointer to 'void *' is disallowed with ARC - sqlite3 在 Objective-C 中,arc 不允许将 int 隐式转换为 NSString - implicit conversion of int to NSString is disallowed with arc in Objective-C ARC不允许将非Object-C指针类型void *隐式转换为NSString * __ strong * - Implicit conversion of a non-Objective-C pointer type void* to NSString*__strong* is disallowed with ARC ARC 不允许目标 c 类型指针“CFDataRef”的隐式转换? - implicit conversion of objective c type pointer 'CFDataRef' is disallowed with ARC? ARC不允许将非Objective-C指针类型'void *'隐式转换为'__unsafe_unretained id *' - Implicit conversion of a non-Objective-C pointer type 'void *' to '__unsafe_unretained id *' is disallowed with ARC 将属性移动到.h文件后,ARC不允许将Objective-C指针隐式转换为“ int *” - Implicit conversion of an Objective-C pointer to 'int *' is disallowed with ARC after move property to .h file
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM