Reputation: 119
I have table view with rows...after I selecting one item I want to show tableView with a new data source.
I tried to implement:
-(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
[self.searchDisplayController setActive:YES animated:YES];
Game *game = [self.filteredListContent objectAtIndex:indexPath.row];
//name your class names with capitals
NSMutableArray *arrayToBeAdded= [[NSMutableArray alloc]initWithArray:newgamearray];
[ListContent removeAllObjects];
[ListContent addObject:arrayToBeAdded];
but I getting exeption in the
[ListContent removeAllObjects];
Implementation of the init:
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
static NSString *CellID = @"cellSgames";
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellID];
if (cell == nil)
{
cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellID] autorelease];
cell.accessoryType = UITableViewCellAccessoryDisclosureIndicator;
}
Gmage *game = [self.ListContent objectAtIndex:indexPath.row];
In the .h file i declare:
NSArray AllList;
NSMutableArray ListContent;
any ideas?
Upvotes: 0
Views: 234
Reputation: 1043
Normally if you are resetting the array in didselect method and reloading your table view with new content it should work.
In your case i think at line: [ListContent removeAllObjects];
ListContent is not a valid pointer. I don't see a reason to crash it here.
Upvotes: 0
Reputation: 9453
Instead of manipulating the current list, create new UITableViewController with your desired data source. If you are using the UINavigationController it will create a better user experience and you will avoid your current problem.
Example:
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
InnerTableViewController *innerTVC = [[InnerTableViewController alloc] initWithNibName:@"InnerTableViewController" bundle:nil];
[self.navigationController pushViewController:innerTVC animated:YES];
[innerTVC release];
}
Upvotes: 3