- (void)searchBarSearchButtonClicked:(UISearchBar *)searchBar
{
   NSLog(@"Wyszukaj: %@", searchBar.text);
   NSString *api = @"http://ajax.googleapis.com/ajax/"
      "services/search/images?v=1.0&rsz=large&q=";
   NSString *urlString = [NSString 
      stringWithFormat:@"%@real%%20estate%%20%@", 
      api,
      [searchBar.text stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding]];
   NSURL *url = [NSURL URLWithString:urlString];

   // Pobranie standardowej kolejki globalnej o priorytecie domyślnym.
   dispatch_queue_t defQueue = 
      dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0);

   void (^imageAPIBlock)(void);

   imageAPIBlock = ^{
      [NSThread sleepForTimeInterval:1.5];
      NSData *data = [NSData dataWithContentsOfURL:url];
      NSString *res = [[NSString alloc] initWithData:data 
                                            encoding:NSUTF8StringEncoding];
      NSArray *newResults = 
         [[[res JSONValue] objectForKey:@"responseData"] objectForKey:@"results"];
      [res release];
      dispatch_async(dispatch_get_main_queue(), ^{
         self.results = newResults;
         [self.tableView reloadData];
      });
   };

   dispatch_async(defQueue, imageAPIBlock);

   [searchBar resignFirstResponder];
}
