![](/img/trans.png)
[英]Implicit conversion of an Objective-C pointer to 'const char *' is disallowed with ARC?
[英]ARC conversion of TPMultiLayoutViewController; Implicit conversion of an Objective-C pointer to 'const void *' is disallowed with ARC
我正在尝试在使用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];
}
}
}
由于以下原因,您遇到了错误:
[NSValue valueWithPointer:associatedView]
由于valueWithPointer:
需要const char *
。 您可以通过执行@ user1139069建议的方法来解决此问题:
[NSValue valueWithPointer:(__bridge void *)associatedView]
如果您使用[NSValue valueWithNonretainedObject:]
而不是[NSValue valueWithPointer:]
怎么办?
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.