Цель-C: Как получить доступ к родительским свойствам из подклассов?

Если я определил этот класс, как мне получить доступ к свойству someObject в подклассах без ошибок компилятора?

@interface MyBaseClass
  // someObject property not declared here because I want it to be scoped 
  // protected. Only this class instance and subclass instances should be
  // able to see the someObject property.
@end

// This is a private interface extension...properties declared here
// won't be visible to subclasses. However, I don't see any way to 
// declare protected properties...
@interface MyBaseClass (private)
   @property (nonatomic, readwrite, retain) NSObject *someObject;
@end

@interface MySubclass : MyBaseClass 
@end

@implementation MySubclass

- (id) init {
    // Try to do something with the super classes' someObject property. 
    // Always throws compile errors.

    // Semantic Issue: Property 'someObject' not found 
    // object of type 'MySubclass *'
    self.someObject = nil; 

}
@end



] Очевидно, я не понимаю, как работает наследование в objective-c. Может ли кто-нибудь просветить меня?

45
задан memmons 24 October 2012 в 14:18
поделиться