Note that there are some explanatory texts on larger screens.

plurals
  1. POCan't assign to the UILabel of custom cell of searchResultsTableView
    primarykey
    data
    text
    <p>Everything works but can't assign value to the UILable of custom cell of searchResultsTableView. I am using the same custom UITableViewCell for my table view controller and it's searchDisplayController. I am using storyboard for the table view controller and table view cell. As you can see in the code, if I NSLog the value of self.searchResults[indexPath.row][@"name"], I can see the result in the console, but if I assign this value to cell.name.text, it won't work, but in the table view controller, it's working. The cell's imageView is working, I just can't assign any value to the cell's UILabel.</p> <pre><code>- (void)viewDidLoad { [super viewDidLoad]; [self.searchDisplayController.searchResultsTableView registerClass:[LocalCell class] forCellReuseIdentifier:@"Cell2"]; } - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { static NSString *CellIdentifier = @"Cell"; static NSString *CellIdentifier2 = @"Cell2"; if (tableView == self.searchDisplayController.searchResultsTableView) { LocalCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier2 forIndexPath:indexPath]; if (!cell) { cell = [[LocalCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier2]; } cell.name.text = self.searchResults[indexPath.row][@"name"]; NSLog(@"%@", self.searchResults[indexPath.row][@"name"]); // has value NSLog(@"%@", cell.name.text); // null return cell; } else { LocalCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier forIndexPath:indexPath]; if (!cell) { cell = [[LocalCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier]; } cell.name.text = self.restaurants[indexPath.row][@"name"]; return cell; } } - (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath { return 80; } - (void)searchBarSearchButtonClicked:(UISearchBar *)searchBar { float radius = 1000.0f; NSString *searchContent = [searchBar.text stringByReplacingOccurrencesOfString:@" " withString:@"%20"]; if ([searchContent length] &gt; 0) { NSString *urlString = [NSString stringWithFormat:@"https://maps.googleapis.com/maps/api/place/nearbysearch/json?location=%f,%f&amp;radius=%f&amp;types=food&amp;key=%@&amp;sensor=true&amp;name=%@", [[[NSUserDefaults standardUserDefaults] objectForKey:@"lat"] floatValue], [[[NSUserDefaults standardUserDefaults] objectForKey:@"lon"] floatValue], radius, AppKey, searchContent]; __weak LocalViewController *weakSelf = self; NSURLSessionConfiguration *config = [NSURLSessionConfiguration defaultSessionConfiguration]; NSURLSession *session = [NSURLSession sessionWithConfiguration:config]; NSURLSessionDataTask *taks = [session dataTaskWithRequest:[NSURLRequest requestWithURL:[NSURL URLWithString:urlString]] completionHandler:^(NSData *data, NSURLResponse *response, NSError *error) { if (!error) { NSDictionary *dict = [NSJSONSerialization JSONObjectWithData:data options:NSJSONReadingAllowFragments error:nil]; weakSelf.nextPageToken = dict[@"next_page_token"]; weakSelf.searchResults = dict[@"results"]; NSLog(@"search results: %@", weakSelf.searchResults); dispatch_async(dispatch_get_main_queue(), ^{ [weakSelf.searchDisplayController.searchResultsTableView reloadData]; }); } }]; [taks resume]; } } </code></pre> <p>LocalCell.h</p> <pre><code>#import &lt;UIKit/UIKit.h&gt; @interface LocalCell : UITableViewCell @property (weak, nonatomic) IBOutlet UILabel *name; @property (weak, nonatomic) IBOutlet UIImageView *imageView; @property (weak, nonatomic) IBOutlet UILabel *desc; @property (weak, nonatomic) IBOutlet UILabel *distance; @end </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. 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