I know a question like this has been posted before, but I was trying to get a direct answer specific to my code. I have seen the other post and have followed it to get to this stage.
I have the (null) libc++abi.dylib: terminate called throwing an exception
line in my log. I have traced it to this line of code:
normalCell.textLabel.text = [[displayArray objectAtIndex:indexPath.row] objectForKey:@"name"];
this is in my cellForRowAtIndexPath
method which has this code:
static NSString *normalCellIdentifier = @"normalCell";
static NSString *topRowCellIdentifier = @"topRowCell";
UITableViewCell *normalCell = [tableView dequeueReusableCellWithIdentifier:normalCellIdentifier];
if (normalCell == nil)
{
normalCell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:normalCellIdentifier];
}
UITableViewCell *topRowCell = [tableView dequeueReusableCellWithIdentifier:topRowCellIdentifier];
if (topRowCell == nil)
{
topRowCell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:topRowCellIdentifier];
}
// Configure the cell...
if (searchBar.selectedScopeButtonIndex != 0)
{
normalCell.textLabel.text = [[displayArray objectAtIndex:indexPath.row] objectForKey:@"name"];
}
if (segmentedControl.selectedSegmentIndex == 0)
{
if (indexPath.section == 0)
{
[self makeButtonsForTableView:tableView atIndexPath:indexPath withTableViewCell:topRowCell];
[topRowCell addSubview:button1];
[topRowCell addSubview:button2];
topRowCell.selectionStyle = UITableViewCellSelectionStyleNone;
return topRowCell;
}
else
{
return normalCell;
}
}
else
{
return normalCell;
}
The makeButtonsForTableView
has all my code for the button, but that isn't the problem because I have removed that from the code and the problem still persists so I don't need to include that.
The displayArray
varies its contents depending on the selectedSegmentIndex
on a UISegmentedControl
and on a UISearchBar
's selected scope.
Each of the Arrays it gets its values from import from my website domain, the arrays are: modsArray itemsArray serversArray pluginsArray newItemsArray newBlocksArray newMobsArray
Thanks for any help you can give.
-- EDIT 22:40GMT - 27/09/2012 --
So I logged the contents of displayArray
when the app loads, and this is the log
2012-09-27 22:39:56.539 AppName[22949:11303] (
)
2012-09-27 22:39:56.675 AppName[22949:11303] (
)
-- EDIT 23:13GMT - 27/09/2012 --
Interestingly, when I change tabs and go back the log changes from this:
2012-09-27 23:13:14.074 MinePedia[23853:11303] DisplayArray Count: 0
2012-09-27 23:13:14.074 MinePedia[23853:11303] IndexPath Row: 0
2012-09-27 23:13:14.355 MinePedia[23853:11303] DisplayArray Count: 0
2012-09-27 23:13:14.355 MinePedia[23853:11303] IndexPath Row: 1
to this
2012-09-27 23:13:14.074 MinePedia[23853:11303] DisplayArray Count: 1
2012-09-27 23:13:14.074 MinePedia[23853:11303] IndexPath Row: 1
2012-09-27 23:13:14.355 MinePedia[23853:11303] DisplayArray Count: 1
2012-09-27 23:13:14.355 MinePedia[23853:11303] IndexPath Row: 0
Anyone know what this means?
-- EDIT 23:42 - 27/09/2012 --
Ok so sort of a different problem than before, it now doesn't crash so thats been solved, thanks Mayur, but now on startup and until the tab is changed at the top, the scope and table view remains with the indexpath being larger than the count. How do I fix this?