Objective-C calling method from super object.
I have an object called 开发者_JAVA百科"Object B", that is spawned by "Object A". Is it possible for Object B to call a method in Object A ?
Object B must have a property that Object A can set.
Like this:
@interface B {
A *a;
}
@property (nonatomic, retain) A *a; // synthesize this
@end
In A:
B *b = [[B alloc] init];
b.a = self;
Then, b can just send messages to a.
Not unless you when spawning "Object B" also pass it a reference to "Object A". For example:
ObjectB* b = [[ObjectB alloc] initWithObjectA:self];
精彩评论