2014-01-24 25 views
0

我需要訪問對象的C函數內類似這樣的一些代碼中如何訪問一個對象的C函數

@interface MixerHostAudio() <UIApplicationDelegate> 
@property (readwrite) int *alternativeOutput; 
@end 

@implementation MyCode 
@synthesize alternative 

void audioInputAvailable() { 
    alternative=1; 
} 

我得到這個錯誤:「‘使用未聲明的標識符的’另類'「

關於如何解決它的任何想法?

+0

如果你想'@ synthesize'一個'@ property'爲比其確切的名稱以外的東西,你必須使用以下格式:' @synthesize propertyName = synthesizedName;'。不過,無論如何,你應該通過'self.'訪問它們的機會相當好。 – nhgrif

+0

請記住,每個實例變量只有在與對象關聯時纔有意義。相反,在一個函數中,因爲它不是一個方法,所以你不能訪問自己,你不是「在一個對象內」。 –

回答

4

您必須使您的「MyCode」對象可用於您的C glue功能。舉例來說,如果你有一個指針,你mycode的對象......

void audioInputAvailable(MyCode *myCodeObject){ 
    myCodeObject.alternative = 1; 
} 
相關問題