A
A
artursk2015-01-02 13:37:24
iOS
artursk, 2015-01-02 13:37:24

How to remove elements from an array when removing a checkmark from a cell?

29927209004b4258aec43561e10cd9b2.pngIn a table of several sections, when removing checkmarkers set in cells, I delete the elements of the pressed cell from the array. removeAtIndex(indexPath.row) works erratically, then only after repeatedly removing checkmarks from a large number of clicked cells, the application crashes, then after the first removal. I can not fully understand how to correctly specify the index of the clicked cell in removeAtIndex. on the screenshot, for example, the application crashed only when the checkmark was removed from the last clicked cell (elements of one cell remained in the array)

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
An, 2015-01-02
@Flanker_4

Why, why do you insert the code with screenshots :(
There is a special tag
On the case: you use an array there as an exercise buffer. If you do everything as you need a dictionary (that is, an associative array)
I'm not sure that nsindexpath is a hashable, but the essence is
When the user marks an object
exercise[indexPath] = obj
When he removes
exercise.removeObjectForKey(indexPath)
I can make mistakes with the method

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question