objective c - Incompatible pointer types returning 'UITableViewCell *__strong' from a function with result type 'UITableView *' -
i loading search results in tableview in following manner getting warning complains incompatible pointer types.
what mistake in code below?
// our tableview containing search results. - (nsinteger)tableview:(uitableview *)tableview numberofrowsinsection:(nsinteger)section { if (searchresults == nil) { return 0; } else { return [searchresults count]; } } - (uitableview *)tableview:(uitableview *)tableview cellforrowatindexpath:(nsindexpath *)indexpath { static nsstring *cellidentifier = @"searchresultcell"; uitableviewcell *cell = [tableview dequeuereusablecellwithidentifier:cellidentifier]; if (cell == nil) { cell = [[uitableviewcell alloc] initwithstyle:uitableviewcellstyledefault reuseidentifier:cellidentifier]; } cell.textlabel.text = [searchresults objectatindex:indexpath.row]; return cell; } // end tableview - (void)searchbarsearchbuttonclicked:(uisearchbar *)searchbar { nslog(@"the search text is: '%@'", searchbar.text); searchresults = [nsmutablearray arraywithcapacity:10]; (int = 0; < 3; i++) { [searchresults addobject:[nsstring stringwithformat:@"fake result %d '%@'", i, searchbar.text]]; } [self.tableview reloaddata]; }
the return type of tableview:cellforrowatindexpath: incorrect. should uitableviewcell * instead of uitableview *.
Comments
Post a Comment