我正在尝试在使用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];
}
}
}
答案 0 :(得分:5)
因为这个原因你得到了错误:
[NSValue valueWithPointer:associatedView]
由于valueWithPointer:
需要const char *
。您可以通过执行@ user1139069建议:
[NSValue valueWithPointer:(__bridge void *)associatedView]
答案 1 :(得分:0)
如果您使用[NSValue valueWithNonretainedObject:]
代替[NSValue valueWithPointer:]
怎么办?