Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>EDIT 1:</p> <p><strong>Your error is here:</strong></p> <pre><code> [self performSelectorOnMainThread:@selector(selector) ----------------------------------^^^^^^^^^^^^^^^^^^^ </code></pre> <p><code>selector</code> is already a selector, and your are putting it in <code>@selector(</code>) again.</p> <p>It should be </p> <pre><code> [self performSelectorOnMainThread:selector withObject:data waitUntilDone:YES]; </code></pre> <hr> <p>Edit 0:</p> <p>Your codes are correct. And you get the error only <strong>when your SEL method in not found in the current class</strong>.</p> <p>As in the code below, if I change the method name <code>sum</code> to <code>add</code> this will throw the same error.</p> <pre><code>-(void)sum{ NSLog(@"sum"); } -(void) createURL: (SEL) selector{ [self performSelector:selector]; } - (IBAction)total:(id)sender { SEL sel = NSSelectorFromString(@"sum"); [self createURL:sel]; } </code></pre> <hr> <p>Also, you need to meet the <strong>method signature</strong> as well. If your method takes one argument, You need to send exactly one.</p> <pre><code>-(void)sum:(id)integer{ NSLog(@"sum:%ld",[integer integerValue]); } -(void) createURL: (SEL) selector{ //NSData* data = [NSData dataWithContentsOfURL: nil]; //[self performSelectorOnMainThread:@selector(selector) withObject:data waitUntilDone:YES]; [self performSelector:selector withObject:@(12)]; } - (IBAction)total:(id)sender { NSInteger total=0; for (id element in self.arrayController.arrangedObjects) { total += [element firstNumber]*[element secondNumber]; } [self.label setStringValue:[NSString stringWithFormat:@"%ld",total]]; SEL sel = NSSelectorFromString(@"sum:"); [self createURL:sel]; } </code></pre>
    singulars
    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. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      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