Lack of Index Validation in UITableViewDelegate and UITableViewDataSource Implementations:
The current implementations of UITableViewDelegate and UITableViewDataSource within the Eureka library encounter issues when indices are beyond the data bounds of the form. Accessing an element with an index outside the bounds of form data leads to application crashes due to out-of-range index access. An optimal solution would involve the library performing index validation, returning default values or handling these cases safely when an index is out of bounds.
Safety Concerns in Form.replaceSubrange and Sections.replaceSubrange Methods:
In the Form.replaceSubrange method, there's an absence of a check to ensure that kvoWrapper._allSections contains the section being removed. The use of force unwrapping in kvoWrapper._allSections.firstIndex(of: section)! can cause the application to crash if the searched section is not found. This issue is also present in the Sections.replaceSubrange method. A safer approach would be to replace force unwrapping with more robust methods like if let or guard statements, ensuring the existence of an index before its usage.
Expected behavior
Index Validation in UITableViewDelegate and UITableViewDataSource:
When interacting with indices in UITableViewDelegate and UITableViewDataSource, the library should safely handle cases where indices are outside the bounds of the form data. Instead of the application crashing, the library should either return default values or gracefully handle these scenarios without causing runtime errors.
Safe Handling in Form.replaceSubrange and Sections.replaceSubrange Methods:
The methods Form.replaceSubrange and Sections.replaceSubrange should include checks to confirm the presence of a section in kvoWrapper._allSections before attempting to modify it. If a section is not found, the methods should fail gracefully, either by safely handling the absence or by providing a clear error message, rather than causing a crash through force unwrapping.
Describe the bug
Lack of Index Validation in UITableViewDelegate and UITableViewDataSource Implementations:
The current implementations of UITableViewDelegate and UITableViewDataSource within the Eureka library encounter issues when indices are beyond the data bounds of the form. Accessing an element with an index outside the bounds of form data leads to application crashes due to out-of-range index access. An optimal solution would involve the library performing index validation, returning default values or handling these cases safely when an index is out of bounds.
Safety Concerns in Form.replaceSubrange and Sections.replaceSubrange Methods:
In the Form.replaceSubrange method, there's an absence of a check to ensure that kvoWrapper._allSections contains the section being removed. The use of force unwrapping in kvoWrapper._allSections.firstIndex(of: section)! can cause the application to crash if the searched section is not found. This issue is also present in the Sections.replaceSubrange method. A safer approach would be to replace force unwrapping with more robust methods like if let or guard statements, ensuring the existence of an index before its usage.
Expected behavior
Index Validation in UITableViewDelegate and UITableViewDataSource:
When interacting with indices in UITableViewDelegate and UITableViewDataSource, the library should safely handle cases where indices are outside the bounds of the form data. Instead of the application crashing, the library should either return default values or gracefully handle these scenarios without causing runtime errors.
Safe Handling in Form.replaceSubrange and Sections.replaceSubrange Methods:
The methods Form.replaceSubrange and Sections.replaceSubrange should include checks to confirm the presence of a section in kvoWrapper._allSections before attempting to modify it. If a section is not found, the methods should fail gracefully, either by safely handling the absence or by providing a clear error message, rather than causing a crash through force unwrapping.