Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>You can't use <code>performSelectorInBackground:withObject:</code> for selectors that take multiple arguments. The suggestions other answers give sort of work, but they all assume you can manipulate the method you are calling, which is not always possible (or even a good idea for clarity).</p> <p>I recommend using NSInvocation instead, as it allows multiple arguments, or alternatively using GCD to dispatch a block to a background queue (or any queue other than the main for that matter).</p> <p>Here's an example usage of NSInvocation</p> <pre><code>NSMethodSignature *sig = [[self class] instanceMethodSignatureForSelector:@selector(downloadImage_3:AtIndex:)]; NSInvocation *inv = [NSInvocation invocationWithMethodSignature:sig]; [inv setTarget:self]; [inv setSelector:@selector(downloadImage_3:AtIndex:)]; [inv setArgument:(__bridge void *)@"http://www.google.com" atIndex:2]; NSUInteger i = 1; [inv setArgument:&amp;i atIndex:3]; [inv performSelectorInBackground:@selector(invoke) withObject:nil]; </code></pre> <p>It's worth double checking, I wrote the code in the browser so I might've missed something the compiler will pick up.</p> <p>As additional note, you should really re-think your method naming conventions, a much more standard way to name methods would have the method be named <code>-(void)downloadImage3:(NSString* )path atIndex:(int)i</code>. Notice how atIndex begins with lowercase and how there is no underscore (which just looks weird in the middle of a method name). Also it might be worth noting that using NSUInteger is preferred for the index, as NSArray in general works with NSUIntegers (both should work, but there are cases in which int might not suffice).</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload