开发者

Error: error: expected ')' before 'postData'

How to fix this error ?

E开发者_Python百科rror: error: expected ')' before 'postData'

NSTimer *timer;
timer = [NSTimer scheduledTimerWithTimeInterval:10.0                                         target:self
selector: @selector(postData:@"xyz")
userInfo:nil

                                    repeats: YES];


Functions called as selectors from timers cannot have parameters. If I remember correctly, you can use userInfo, which passes an array or dictionary to the selector.

do something like this:

NSTimer *timer;
timer = [NSTimer scheduledTimerWithTimeInterval:10.0
         target:self
         selector: @selector(postData:)
         userInfo:@"xyz"
         repeats: YES];

- (void)postData:(NSTimer*)timer {
    NSLog(@"userInfo = %@", timer.userInfo);
}


When we read the documentation of the method you are using, it seems it's not correctly called :

timer = [NSTimer scheduledTimerWithTimeInterval:10.0
target:self
selector:@selector(postData:)
userInfo:nil
repeats:YES];

And your postData must have the following signature :

- (void)postData:(NSTimer*)theTimer
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜