8
votes

I am trying to accomplish this:

Consider a table view with Search Bar on its header.Table view gets refreshed whenever string is searched.

I am having 2 classes

TableViewController(UIViewController subclass)

contains UITableView -That shows the table whose

header view of the table is loaded from the Header class(UIToolBar subclass)

.

Header(header of the UITableView)
-Contains UISearchBar and its delegate

The

UISearchBarDelegates call back a function in TableViewController

that calls

- (void)reloadSections:(NSIndexSet *)sections withRowAnimation:(UITableViewRowAnimation)animation  

which causes App to crash

The function call stack frame is as follows

[UITableView reloadSections:withRowAnimation:]  
[TableViewController functionThatCallsReloadSection]  
[Header searchBarSearchButtonClicked:]  

The reloadSection is causing the App to crash .Any ideas why its happening so?

Is it because the delegate function is still active on the stack while the the table view header is reloaded??

I am not changing any anything related to the tableview (no change in the number of rows or sections).All i am trying to doing is to just reload the table view.

Edited: I am trying to do all these things in iPad,which provides a popover while using UISearchDisplayController which i dont want to use.I already have a table view which i want to refresh once the text is entered and search button is hit,using the search delegate. The only problem is that once i call [UITableView reloadSection:] in the search delegate of UISearchBar(UISearchBar is located on the header of the UITableView that i want to reload) the app crashes.

1
should i implement the search bar as a different toolbar and not as a header of the table view?prajul
eventhough the app dosent crash if i perform a reloadData instead of the reload section,the app will crash once it encounter a reloadSection for the same table some where in the codeprajul

1 Answers

1
votes

I was able to fix the problem by using the tableViewHeader instead of loadind the table view header using the table view header delegate method where i used a pointer thats initialised to the table view header.