문제

This code gives me the error Cannot find interface declaration for 'OGWView':

typedef SKNode OGWView;

@interface OGWView (Category)
@end

Why? Shouldn't the category work just as well with a typedef name?

PS: I know I can fix this with a #define (or by using the original class name) but I'm really more interested in understanding why it isn't possible to create a category on a typedef class.

도움이 되었습니까?

해결책

I believe the answer to this question is that you have 2 different kinds of symbol. I believe the typedef is an object and you are trying to use it as a class symbol.

depending on the order of declaration you get different warnings suggesting as much:

typedef NSObject Foo;
@class Foo;

yields:

Redefinition of forward class 'Foo' of a typedef name of an object type is ignored

@class Foo;
typedef NSObject Foo;

yields:

Redefinition of 'Foo' as different kind of symbol

다른 팁

Replace typedef with @compatibility_alias

@compatibility_alias SKNode OGWView;
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top