[SWIFT] I think I understand the reuse of cells, but I don't understand at all.

Summary

Please tell me the exact content ... (Other power application)

Premise

If you try to create a tableView cell by creating an instance every time, it will become heavier and heavier as the number of cells increases. So I think it was a story about "reusing" cells.

The big problem that happened this time

I implemented a scrolling table using a very convenient library called SpreadsheetView. The table to be implemented is of the type with some empty space (like a timetable). If you scroll, the empty space will be filled up more and more! Every time I scroll, it fills up more and more, and in the end it seems that there is almost no space ...

Solution

After calling the cell, put empty data in the empty space.

Why this solves

From here, I'm guessing because I haven't verified it properly or studied it. (1) "Reusing" a cell means reusing it including properties. (Since it does not create a new instance, the property will not be initialized unless you write the initialization process) (2) The cellForRowAt method was called every time I scrolled (this has been confirmed). Probably, cellForRowAt is called for the cell that appears at the timing when the part that disappeared before scrolling appears. ③ Because it is "reused", the property at the time of reuse is applied when drawing the empty space → Will the empty space fill up more and more? ??

Therefore, by replacing the properties at the time of reuse with empty data, it can be safely kept empty even if it is redrawn.

After all

Can anyone please tell me the exact content ... (I will study it later m (_ _) m)

Recommended Posts

I think I understand the reuse of cells, but I don't understand at all.
docker What should I do first? (Somehow I understand the shell, but ... for beginners at the level)
I didn't understand the behavior of Java Scanner and .nextLine ().
I took a peek at the contents of Java's HashMap
Now, I understand the coordinate transformation method of UIView (Swift)
After all, how should I attach the Constraint of ScrollView?
Understand the basics of docker
Java concurrency I don't understand
I don't understand Ruby 3 Ractor
I want to understand the flow of Spring processing request parameters
I took a look at the resources of Azure Container Instance
I examined the concept of the process to understand how Docker works
Don't lose to the unchecked warning! → After all, I couldn't win the unchecked warning ...
I don't understand the devise_parameter_sanitizer method, so I'll output it here.
Understand the basic mechanism of log4j2.xml
I read the source of ArrayList I read
I read the source of Integer
I read the source of Long
Think about the 7 rules of Optional
I read the source of Short
I read the source of Byte
I read the source of String
After all I wanted to preview the contents of mysql with Docker ...