AKB
AKB

Reputation: 122

Table View cell index's stored in an array is losing when scrolling

i'm working on table view for last few days. but, now i'm stuck. actually, what m i doin' is that i i want to store cell indexes into a mutable array. i'd done this part. but, as i scroll the table view, the data stored in the array gets refreshed and the indexes that i stored gets removed from that mutable array. here's the code what i have done so far....

} } Please help me. thankx in advance....

Upvotes: 1

Views: 903

Answers (1)

Roshit
Roshit

Reputation: 1579

Is it the names MutableArray that is getting refreshed ? If so, it is because you are initializing it everytime a cell is selected. Thus ending up in deleting the previously set value.

  • Initialize the names array outsite the delegate. maybe in viewDidLoad or where ever you intialize the TableView

  • In didSelect, add the new object in the names array

Also, it is bad logic to create all the loadnameX in the cellForRowAtIndexPath and add to newly initialized mTFArrayOfNames.

  • Remove this entire logic from cellForRowAtIndexPath and add it to viewDidLoad or where ever you intialize the TableView

Upvotes: 0

Related Questions