Evgeniy Kleban Evgeniy Kleban - 4 months ago 29
iOS Question

Exc bad access in table view - iOS

I have an array that fill when user click search button. If there is no data for that response, server return empty response and therefore here is an empty array. I wonder, why when i fire fake request it return me

EXC_BAD_ACCESS (code=1, address = 0xa)
.

It point to:

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{

if (_arrValues.count > 0)
return self.arrValues.count;

return 0;
}


To line:

if (_arrValues.count > 0)


In
viewDidLoad
I did allocate an array like that:

_arrValues = @[];


So, I cant understand why this occurs. Any suggestions?

In debugger it simply prints an array memory and ISA pointer, obviously there is no data if user search fake request that return nothing.

From debug panel:

enter image description here

When I update my server part like that (remove response and always create an empty array) problem is disappeared. Probably there is an issue in my request/mapping part:

// _arrValues = [eventsMgr getEventsFromResponse:x];
_arrValues = @[];

Answer

Use This Code

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
    return [_arrValues count];
}