2012-01-26 50 views
1

我想使用ARC項目中使用TPMultiLayoutViewController,但我碰到下面的錯誤: -TPMultiLayoutViewController的ARC轉換; Objective-C的指針,以「常量無效*」的隱式轉換是不允許與ARC

Implicit conversion of an Objective-C pointer to 'const void *' is disallowed with ARC

我我真的不知道如何解決這個問題。它需要明確轉換嗎?我該怎麼做?

- (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

哪條線有錯誤? – Mark

+0

第一個在方法 '[table setObject:[self attributesForView:view] forKey:[NSValue valueWithPointer:associatedView]];' – akbsteam

+0

它的這部分特別是'[NSValue valueWithPointer:associatedView]' – akbsteam

回答

5

你得到,因爲這個錯誤:

[NSValue valueWithPointer:associatedView] 

由於valueWithPointer:需要const char *。你可以解決這個做什麼@ user1139069建議:

[NSValue valueWithPointer:(__bridge void *)associatedView] 
0

如果使用[NSValue valueWithNonretainedObject:]代替[NSValue valueWithPointer:]什麼?

相關問題