Frage

I'm pretty new to Objective-C. Most of my experience is in Java. I have a base class:

@interface Bug : NSObject <BugProtocol> {

    @private
    World* world;
    NSString* name;
    NSString* layer;
    long x;
    long y;
    BOOL alive;

...
...


}

...
...

@end

and a class that extends this base class:

@interface RandomBug : Bug
    ...
    ...
@end

However, when I try to access properties that I've defined in the parent class, the compiler complains that it cannot find them. Most of the examples I've seen for access properties is tailored towards OS X (i.e., using things like @property which, as far as I know, is not fully supported in GNUStep).

War es hilfreich?

Lösung

I figured it out. I just need to use @protected (just like in Java):

@interface Bug : NSObject <BugProtocol> {

    @protected
    World* world;
    NSString* name;
    NSString* layer;
    long x;
    long y;
    BOOL alive;

...
...


}

...
...

@end
Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit StackOverflow
scroll top