2012-10-24 66 views
1

我根據README文件安裝了所有東西,並導入了所有必需的庫。不過,實施這種方法時:ARC與CorePlot問題

- (CPTLayer *)dataLabelForPlot:(CPTPlot *)plot recordIndex:(NSUInteger)index { 
    CPTMutableTextStyle *labelText = nil; 
    labelText= [[CPTMutableTextStyle alloc] init]; 
    labelText.color = [CPTColor grayColor]; 

    return [[CPTTextLayer alloc] initWithText:@"Test" style:labelText]; 
} 

我收到錯誤:

ARC Semantic issue - Receiver 'CPTTextLayer' for class message is a forward declarationARC Semantic issue - Receiver 'CPTTextLayer' for instance message is a forward declaration

我在很多帖子閱讀,這是缺少Quartz庫的錯,但我有它在項目中導入幷包含在課程中:#import <QuartzCore/QuartzCore.h>

當我返回nil而不是這樣,一切正常,但嘿,我需要這些數據標籤工作!

任何人都知道如何使它工作?

+0

你試過導入CPTTextLayer.h嗎? – borrrden

+0

我沒有想到**那** ......爲什麼Xcode不向我大聲說它需要導入? – Michal

+3

這樣做,你只是不明白的消息:第 – borrrden

回答

1

通常forward class error出現在當前類中未導入該特定類並且在.h文件中聲明@class。如果@class也不存在,則通常給出unknown type error。因此,在評論中提到的這種情況下,顯然缺少CPTTextLayer的進口聲明。

1

我覺得你忘了在你的代碼上導入CPTTextLayer.h