2

I'm making a table which you can search for different entries. It works just fine when you search but now I want to load the tableview by pressing a button. But when running:

[self.tableView reloadData];

cellForRowAtIndexPath is not getting called?! I've read numerous of people having similar problems but clearly I don't manage to understand their solution to the problem. Help me :)

My header file:

@protocol SearchViewControllerDelegate;

@interface SearchViewController : UIViewController <UISearchBarDelegate, UITableViewDelegate, UITableViewDataSource> {
    id <SearchViewControllerDelegate> delegate;

    NSMutableArray *listOfItems;
    NSMutableArray *listOfItemsDynamic;
    UITableView *tableView;
    IBOutlet UISearchBar *sBar;
}

@property (nonatomic, assign) id <SearchViewControllerDelegate> delegate;
@property (nonatomic, retain) UITableView *tableView;
- (void) searchTableView:(NSString *) searchText;
- (IBAction)done:(id)sender;
- (IBAction)refresh:(id)sender;
@end

@protocol SearchViewControllerDelegate
- (void)searchViewControllerDidFinish:(SearchViewController *)controller;
@end

Some of the source code:

@implementation SearchViewController

@synthesize delegate, tableView;
- (void)viewDidLoad {
    [super viewDidLoad];
    ...
}

- (void)searchBar:(UISearchBar *)searchBar textDidChange:(NSString *)searchText {
    [self searchTableView:searchText]; // Search all entries based on user input...
    [self.tableView reloadData]; // Works just fine
}

- (IBAction)refresh:(id)sender {    
    [self searchTableView:@"a"]; // Search all entries containing "a"...
    [self.tableView reloadData]; // FAILS! (cellForRowAtIndexPath not getting called...)
}

Please help me, I'm quite new to objective c and the problem is probably related to how delegates works etc...

user872661
  • 251
  • 2
  • 13
  • Ah fixed it, the UITableView's "dataSource" wasn't connected to "File's Owner". After solving that in the Interface Builder it now works... – user872661 Aug 21 '11 at 10:19

0 Answers0