views:

251

answers:

3

I received an EXC_BAD_ACCESS when I try scroll up past the top or scroll down past the max position of the table view. This does not happen when tableview is empty but as soon as I add data to table cell and try to scroll up or down to far, I get an "EXC_BAD_ACCESS".

Is there a way to prevent the user from scrolling too far?

A: 

The problem isn't that the user is scrolling to far, the problem is that you are giving the table bad row indexes. The table believes it is larger than it actually has data for.

Check what you return from – numberOfSectionsInTableView: and –tableView:numberOfRowsInSection:. Those methods are where your problem most likely arises from.

TechZen
-numberOfSectionInTableView, I return 1. -tableView:numberOfRowsInSection, I return [drinkList count]. 'drinkList' is the array that hold data that need to display onto the viewtable
Harry Pham
I'd need to see your code. I can just tell you what causes this kind of crash. Set breakpoints or logs for the index in `cellForRowAtIndex` and it will show you where it goes out of bounds.
TechZen
+1  A: 

Hi! Once i had also a problem like this! maybe something is wrong with your deallocation, that means you release any objects too fast! I can't tell you exactly what's wrong, you should post some code, especially the cellForRowAtIndexPath method. So far, check out this method on your own and try to find any dealloc problems.

burki
Bingo !!!! thank you so much
Harry Pham
+1  A: 

Thanks a lot to @burki. In case anyone is having the same issue I solved it by removing 'autorelease' from my dequeueReusableCellWithIdentifier when I was using a custom cell type.

Andrew Kozlik