2012-02-28 3 views
3

만약 내가 다음 프로토콜을 사용하고 그 프로토콜을 사용하는 인터페이스를 가지고 있다면, btouch를위한 ApiDefinition을 설정하는 올바른 방법은 무엇입니까? 나는 대부분의 .h 파일을 변환했지만이 파일은 나를 속이는 것이다. 당신이 중 하나를 단순히 클래스에 직접 속성을 인라인하거나 발전기가 당신을 위해 그 인라인 할 수 있도록프로토콜을위한 모노 터치 바인딩 구문

감사

제프

@protocol GRGrabbaPreferencesProtocol <NSObject> 
- (NSString*) baseNamepace; 
@end 

@interface GRGrabbaPreferences : NSObject <GRGrabbaPreferencesProtocol> 
{ 
    GRGrabbaBarcodePrefs *barcode; 
} 
@property (retain) GRGrabbaBarcodePrefs *barcode; 
@end 

@interface GRGrabbaBarcodePrefs : NSObject <GRGrabbaPreferencesProtocol> 
@end 

답변

4

프로토콜은 정말, 당신의 인터페이스에 인라인된다.

[BaseType (typeof (NSObject))] 
interface GRGrabbaPreferences : GRGrabbaPreferencesProtocol { 
    [Export ("baseName")] 
    string BaseName { get; } 

    [Export ("barcode")] 
    GRGrabbaBarcodePrefs Barcode { get; } 
} 

[BaseType (typeof (NSObject))] 
interface GRGrabbaBarcodePrefs : GRGrabbaPreferencesProtocol { 
    [Export ("baseName")] 
    string BaseName { get; } 
} 

발전기는 오류 및 잘라 내기/붙여 넣기 문제를 방지하기 위해 인라인을 인수하게하는 것이 더 실용적입니다 :

// Notice the lack of [BaseType] attribute on this one 
interface GRGrabbaPreferencesProtocol { 
    [Export ("baseName")] 
    string BaseName { get; } 
} 

[BaseType (typeof (NSObject))] 
interface GRGrabbaPreferences : GRGrabbaPreferencesProtocol { 
    [Export ("barcode")] 
    GRGrabbaBarcodePrefs Barcode { get; } 
} 

[BaseType (typeof (NSObject))] 
interface GRGrabbaBarcodePrefs : GRGrabbaPreferencesProtocol { 
} 

은 동일합니다. 그러나 GRGrabbaPreferencesProtocol은 어떤 형태로든 C#으로 내보내지지 않습니다.