title: Sending API Data to UITableView Within ViewController
body: <p>Having trouble filling a TableView within a ViewController (not a TableViewController) with data from the Google Places API.</p>
  
  <p>I'm already pulling data successfully and parsing the JSON to a MKMapView with annotations, so I know that part's working, but I want the data to also flow into the table below it (see photo).</p>
  
  <p><img src="https://i.stack.imgur.com/iH0CB.png" alt="Example layout of MapView with TableView below"></p>
  
  <p>I've looked everywhere for a simple explanation of how to do this. Even followed a tutorial (but it was meant for a TableViewController, so I'm hoping my issue is just the way I've linked it). Another possibility is the placement of my <code>[self.tableView reloadData];</code> call. It made logical sense to me, but could very well be in the wrong place. Apparently the TableView will remain blank if that's not in the right spot, but I've tried it in several places.</p>
  
  <p>Note: I've only included the pertaining code to hopefully make it easier for you guys to spot. The TableView object is connected to the ViewController as its data source and delegate, the prototype cell is called "Cell" in the Attribute Editor as called in the #pragma code, and the JSON data is being stored in an NSArray called "places". Please let me know if you spot something stupid that I've missed that's causing this to not work and thanks in advance.</p>
  
  <h2>ViewController.h</h2>
  
  <pre><code>@interface RendezvousViewController : UIViewController &lt;UITableViewDataSource, UITableViewDelegate&gt;
  
  @property (strong, nonatomic)          NSArray *places;
  @property (strong, nonatomic) IBOutlet UITableView *tableView;
  </code></pre>
  
  <h2>ViewController.m</h2>
  
  <pre><code>    -(void)viewDidLoad {
          self.tableView.dataSource = self;
          self.tableView.delegate = self;
  }    
  
      -(void) queryGooglePlaces: (NSString *) googleType {
              // Build the url string to send to Google.
              NSString *url = [NSString stringWithFormat:@"https://maps.googleapis.com/maps/api/place/nearbysearch/json?location=%f,%f&amp;radius=%@&amp;types=food|restaurant|bar&amp;sensor=true&amp;keyword=%@&amp;key=%@",currentCentre.latitude,currentC
  
  entre.longitude,[NSString stringWithFormat:@"%i",currenDist],selection, kGOOGLE_API_KEY];
          url = [url stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding];
  
          NSLog(@"%@", url);
  
          //Formulate the string as a URL object.
          NSURL *googleRequestURL=[NSURL URLWithString:url];
  
          // Retrieve the results of the URL.
          dispatch_async(kBgQueue, ^{
              NSData* data = [NSData dataWithContentsOfURL: googleRequestURL];
              [self performSelectorOnMainThread:@selector(fetchedData:) withObject:data waitUntilDone:YES];
  
          });
      }
  
          -(void)fetchedData:(NSData *)responseData {
              //parse out the json data
              NSError* error;
              NSDictionary* json = [NSJSONSerialization
                                    JSONObjectWithData:responseData
  
                                    options:kNilOptions
                                    error:&amp;error];
  
              //The results from Google will be an array obtained from the NSDictionary object with the key "results".
              NSArray* places = [json objectForKey:@"results"];
  
              //Write out the data to the console.
              NSLog(@"Google Data: %@", places);
  
              [self plotPositions:places];
              [self.tableView reloadData];
          }
  
      #pragma mark - Table view data source
  
      - (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
      {
          // Return the number of sections.
          return 1;
      }
  
      - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
      {
          // Return the number of rows in the section.
          return [self.places count];
      }
  
      - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
      {
          static NSString *CellIdentifier = @"Cell";
          UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier forIndexPath:indexPath];
  
          NSDictionary *tempDictionary= [self.places objectAtIndex:indexPath.row];
  
          cell.textLabel.text = [tempDictionary objectForKey:@"name"];
  
          if([tempDictionary objectForKey:@"rating"] != NULL)
          {
              cell.detailTextLabel.text = [NSString stringWithFormat:@"Rating: %@ of 5",[tempDictionary   objectForKey:@"rating"]];
          }
          else
          {
              cell.detailTextLabel.text = [NSString stringWithFormat:@"Not Rated"];
          }
  
          return cell;
      }
  </code></pre>