title: Return a variable from inside a block
body: <p>Below I have some code which should return an array, the response from the server happens in a block:</p>
  
  <pre><code>- (NSMutableArray *)getArray
  {
      NSMutableDictionary* params =[NSMutableDictionary dictionaryWithObjectsAndKeys:
                                    @"pending", @"command",
                                    @"2" , @"userID",
                                    nil];
  
      [[API sharedInstance] commandWithParams:params
                                 onCompletion:^(NSDictionary *json) {
                                     //result returned
  
  
                                     if ([json objectForKey:@"error"]==nil) {
                                         NSMutableArray *res = [[NSMutableArray alloc] init];
                                         [res addObject:@"1234"];
  
                                         RETURN HERE
  
                                     } else {
                                         //error
                                         [UIAlertView title:@"Error" withMessage:[json objectForKey:@"error"]];
                                     }
  
                                 }];
  }
  </code></pre>
  
  <p>After parsing the data and creating an array I want to return the array I have created for the <code>getArray</code> method call. So far, after hours of trying I have not had any luck, even with trying some suggestions from previous questions on stackoverflow. Any help would be appreciated.</p>