【发布时间】:2010-09-22 18:20:33
【问题描述】:
我正在研究一个具有方法 -(void)DoSmthing1 的 A 类。我正在打电话给 B类中的另一个方法-(void)DoSmthing2。现在在B类中做了一些操作后,该方法应该回调一个方法-(void)DoSmthing3之前的类。
如何从另一个类调用当前类的方法?谁能帮帮我....
提前致谢
编辑1:: 我的代码: A类
{
-(void) MethodA {
}
-(void) MethodB {
ClassB *clsB = [[ClassB alloc] init];
[clsB MethodC];
}
}
B类
{
-(void)MethodC:(selector) {
//here i want to call MethodA of classA, and i will prefer if it is possible by sending the name of the method as selector in this method(methodC)
}
}
edit2::
另一个我想做的例子如下:
ClassB *b = [[ClassB alloc] nitWithTarget:self selector:@selector(methodfromClassA) object:nil];
在这里,我想在 B 类中的某些任务完成后调用 A 类的方法,并且也从 A 类中调用。
我希望现在已经很清楚了。
编辑3:
- (void)loadView {
AsyncConnection *async =[[AsyncConnection alloc] init];
[async getAsync:self callback:@selector(test1)];
}
以上代码来自第一类
-(void)getAsync:(id)anObject callback:(SEL)selector {
NSInvocationOperation *operation = [[NSInvocationOperation alloc] initWithTarget:anObject
selector:@selector(selector)
object:nil];
[queue addOperation:operation];
[operation release];
}
以上代码来自二等舱。这里我想调用一个作为选择器传递的第一类方法。
【问题讨论】:
标签: iphone objective-c cocoa oop