开发者

Having trouble passing object to selector [closed]

开发者 https://www.devze.com 2023-02-07 05:25 出处:网络
Closed. This question is not reproducible or was caused by typos. It is not currently accepting answers.
Closed. This question is not reproducible or was caused by typos. It is not currently accepting answers.

This question was caused by a typo or a problem that can no longer be reproduced. While similar questions may be on-topic here, this one was resolved in a way less likely to help future readers.

Closed 6 years ago.

Improve this question

I am performing a data download in the background and have a progress bar view displayed on the screen. The progress bar isn't being updated during the download (on the screen anyway, I'm updating it in the code), it merely sits at empty until the download is done and then goes full before disappearing. Thinking that the problem is that I have to pass the progress view object to the download routine I tried calling it as follows:

[self performSelectorInBackground:@selector(downloadData) withObject:pBarView];

Which calls:

-(void)downloadData:(UIProgressView *) pView {
}

When it tries to execute I get the following error:

*** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '*** -[NSThread initWithTarget:selector:object:]: target does not implement selector (*** -[RootViewController downloadData])

I'm thinking this is probably not the way to solve this, but at this point I'm pressing butto开发者_开发技巧ns and flipping switches as the ground gets larger in the windshield. If it's wrong, I'd appreciate some guidance as to how to get the progress bar update working. Either way, it appears that I am calling the downloadData method with same typed parameters so my thinking is that I shouldn't be getting the error. Obviously there is something I am missing here. I've looked at the NSObject docs until my eyes crossed.


You missed a colon in your selector. That colon represents the single object argument your method takes; otherwise the program is trying to find a method downloadData that doesn't take arguments, then ends up crashing.

This should work:

[self performSelectorInBackground:@selector(downloadData:) withObject:pBarView];
0

精彩评论

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