例如:
-(void) myExample {
..do something
}
void myOther(){
how to call myExample function here
}
答案 0 :(得分:0)
如果两个方法都在同一个类中,则可以直接从第二个方法调用First方法,如下所示:
-(void) myExample {
..do something
}
void myOther(){
call to myExample function
[self myExample];
}
答案 1 :(得分:0)
void getInputSource() {
TISInputSourceRef source = TISCopyCurrentKeyboardLayoutInputSource();
NSLog(@"languages: %@", TISGetInputSourceProperty(source, kTISPropertyBundleID));
NSLog(@"localized name: %@", TISGetInputSourceProperty(source, kTISPropertyLocalizedName));
[self awakeFromNib];
}
-(void) awakeFromNib {
self.statusBar = [[NSStatusBar systemStatusBar] statusItemWithLength:NSSquareStatusItemLength];
NSImage* icon = [NSImage imageNamed:@"icon.png"];
self.statusBar.image = icon;
}
答案 2 :(得分:0)
当您致电myOther时,请传递自我参考。你应该像这样定义C方法:
void myOther(id callBack)
现在你在c函数中有自引用。
void myOther(id callBack){
[callBack myExample];
}