Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

If the groups mutable array is emptied at some point before cellForRowAt... #23

Merged
merged 1 commit into from
Jan 7, 2015
Merged

If the groups mutable array is emptied at some point before cellForRowAt... #23

merged 1 commit into from
Jan 7, 2015

Conversation

mamaral
Copy link
Contributor

@mamaral mamaral commented Jan 6, 2015

...IndexPath is called, this can cause a crash.

Intermittently I've come across a crash when taking photos with the camera using this library, and Crashlytics reports this as being an NSRange Exception: Index 0 beyond bounds for empty array as seen below. I've found this a tough nut to crack in terms of reproducibility, but I can say that it only seems to happen when taking a photo. Also, this was mentioned in a side-comment on #20.

screenshot 2015-01-06 11 55 04

This was quite puzzling to me as normally cellForRowAtIndexPath: isn't called when the data source array is empty, so I figured there was some issue where perhaps the groups property on the UzysGroupPickerView was altered without updating the tableview.

In going through the code briefly in an attempt to track down the issue, my understanding is that the UzysAssetsPickerController has a UzysGroupPickerView property that it initializes with the groups mutable array property in the picker controller's view did load process, and there are a few places in which the picker controller updates the groups property on itself without updating the groups property on the groupPicker.

My observations seemed to be the opposite of what I was expecting when I hypothesized the issue, so I figured because you have a better understanding of how this all works perhaps you might know what the issue may be.

Either way this seemingly superfluous check to ensure that the groups count is greater than 0 before attempting to obtain an objectAtIndex: in the groups property of the picker view should at least prevent this crash in the short-term until the deeper cause is determined. Let me know what you think.

…wAtIndexPath is called, this can cause a crash.
uzysjung added a commit that referenced this pull request Jan 7, 2015
If the groups mutable array is emptied at some point before cellForRowAt...
@uzysjung uzysjung merged commit a100748 into uzysjung:master Jan 7, 2015
@uzysjung
Copy link
Owner

uzysjung commented Jan 7, 2015

Thanks mamaral.

@mamaral mamaral deleted the table-view-crash-protection branch January 7, 2015 04:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants