As I am pretty new to ObjC I'm stuck to the following issue:
I have a function downloadFile
-(void) downloadFile:(NSMutableArray*)paramArray withDict:(NSMutableDictionary*)options
{
//do stuff
}
I want to start this as a thread, and therefore I use this line of code:
NSThread* dLoad = [[NSThread alloc] initWithTarget:self selector:@selector(downloadFile:) object:nil];
[dLoad start];
It throws me the following error:
*** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '*** -[NSThread initWithTarget:selector:object:]: target does not implement selector (*** -[LaunchDownload downloadFile:])'
What am I missing over here?
I believe you're not providing enough arguments to your thread. The method you implemented has the signature downloadFile:withDict:
, but you're only providing downloadFile:
. You should give it the correct selector name.
Keep in mind that you will probably run into trouble anyway - the NSThread class reference specifies that methods you call this way must take only one argument. I'd recommend either converting your two arguments to a single NSDictionary that your method parses out or rethinking how you're dispatching this thread.
The method name is downloadFile:withDict:
and not downloadFile: .
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With