title: Perform Method With int Return Value in Background Thread
body: <p>I'm trying to speed up my application performance by performing calculations in background threads but I'm having trouble doing this. Originally I had been using</p>
  
  <pre><code>[self performSelectorInBackground:@selector(calculateValue:) withObject:[words objectAtIndex:row]];
  </code></pre>
  
  <p>which was fine when my selector was a void method. However, I'm trying to do something similar to but obviously the below code isn't valid.</p>
  
  <pre><code>int value = [self performSelectorInBackground:@selector(calculateValue:) withObject:[words objectAtIndex:row]];
  </code></pre>
  
  <p>Any help is greatly appreciated.</p>
  
  <p><strong>Updated</strong></p>
  
  <p>Here is the route I'm currently going. I don't know how to call back to the main thread to send the updated value from computeWordValue to my cellForRowAtIndexPath</p>
  
  <pre><code>- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
      int value = [self performSelectorInBackground:@selector(calculateWordValue:) withObject:[wordsSection objectAtIndex:row]];
      NSString *pointValue = [[NSString alloc] initWithFormat:@"Point:%d",value];
      cell.pointLabel.text = pointValue;
   }
  
  -(void)calculateWordValue:(NSString *)word {
  
    [self performSelectorOnMainThread:@selector(computeWordValue:) withObject:word waitUntilDone:YES];
  }
  
  -(int)computeWordValue:(NSString *)word {
  
    return totalValue; //This will be a randomly generated number
  }
  </code></pre>