【发布时间】:2012-01-26 11:45:03
【问题描述】:
我正在尝试在使用 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];
}
}
}
【问题讨论】:
-
方法中的第一个
[table setObject:[self attributesForView:view] forKey:[NSValue valueWithPointer:associatedView]]; -
这部分特别是
[NSValue valueWithPointer:associatedView] -
为什么不把关联的View直接放到NSDictionary中呢?
-
一般
(__bridge void *)但是我不明白为什么你会在那里得到那个错误。setObject:forKey应该采取id -
你可以使用视图对象作为键吗?
标签: objective-c ios automatic-ref-counting