Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/objective-c/27.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
当作为参数iPhone/iPad传递时,无法执行方法_Iphone_Objective C_Ipad_Pointers - Fatal编程技术网

当作为参数iPhone/iPad传递时,无法执行方法

当作为参数iPhone/iPad传递时,无法执行方法,iphone,objective-c,ipad,pointers,Iphone,Objective C,Ipad,Pointers,我试图学习如何将方法作为参数传递,然后在以后执行它们。在我的代码中,我有一个方法,当我试图将method1和method2传递给方法placeSlide时,单击按钮(最后一个方法)会调用get。我可以这样做,但当我试图执行它们时,我会出错。我做错了什么 -(void) method1{ } -(void) method2{ } -(void) placeSlide: (SEL) meth1 OtherMethod: (SEL) meth2{ NSTimer *timer1;

我试图学习如何将方法作为参数传递,然后在以后执行它们。在我的代码中,我有一个方法,当我试图将method1和method2传递给方法placeSlide时,单击按钮(最后一个方法)会调用get。我可以这样做,但当我试图执行它们时,我会出错。我做错了什么

-(void) method1{

}
-(void) method2{

}

-(void) placeSlide: (SEL) meth1 OtherMethod: (SEL) meth2{




    NSTimer *timer1;
    timer1 = [NSTimer scheduledTimerWithTimeInterval: (1)
                                             target: self
                                           selector: @selector(meth1)
                                           userInfo: nil
                                            repeats: NO];
    NSTimer *timer2;
    timer2 = [NSTimer scheduledTimerWithTimeInterval: (1.2)
                                             target: self
                                           selector: @selector(meth2)
                                           userInfo: nil
                                            repeats: NO];
}

// get's executed when I click on a btn
-(IBAction) ButtonClick{
    [self placeSlide:@selector(method1) OtherMethod:@selector(method2)];
}
我得到的错误是:

只需按原样传递
SEL
变量即可

NSTimer *timer1;
timer1 = [NSTimer scheduledTimerWithTimeInterval: (1)
                                         target: self
                                       selector: meth1
                                       userInfo: nil
                                        repeats: NO];
NSTimer *timer2;
timer2 = [NSTimer scheduledTimerWithTimeInterval: (1.2)
                                         target: self
                                       selector: meth2
                                       userInfo: nil
                                        repeats: NO];

只需按原样传递
SEL
变量即可

NSTimer *timer1;
timer1 = [NSTimer scheduledTimerWithTimeInterval: (1)
                                         target: self
                                       selector: meth1
                                       userInfo: nil
                                        repeats: NO];
NSTimer *timer2;
timer2 = [NSTimer scheduledTimerWithTimeInterval: (1.2)
                                         target: self
                                       selector: meth2
                                       userInfo: nil
                                        repeats: NO];