gpt4 book ai didi

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

转载 作者:行者123 更新时间:2023-12-01 18:01:29 25 4
gpt4 key购买 nike

我正在尝试在使用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]

关于objective-c - TPMultiLayoutViewController的ARC转换; ARC不允许将Objective-C指针隐式转换为“const void *”,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9017676/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com