1
Hello! I have a very simple doubt, because I have already found a solution for it, but it still seems problematic. I will explain:
I created a connection with web service to receive some data, and at the end I am storing this data in a dictionary, which in turn is saved in an array.
However, I need this array to be initialized elsewhere, within the class that will save the data to sqlite. But I don’t know how to initialize this array with the data that was received from the web service.
The solution I found was to use the Appdelegate. Appdelegate would have a variable that will receive this array, and then I would generate an instance of Appdelegate within the class that manages the sqlite database. However, I believe that depending on the amount, and the volume of data in the tables, I could overload the Appdelegate, consuming a lot of memory.
Would anyone know how to solve this problem!
Thank you.
So, using the example, I would have to instantiate Shareddata at one point to receive the data I want, and then the moment I instantiate it again at another point, and it will have in its attribute the data I passed previously? And as for the use of memory, I may need to worry, because in this data that I will receive through the web service I will have some images. I’ll check the size of them with the head of DB.
– Tiago Amaral
Yes, the entire object will be kept in memory during the application lifecycle. You don’t have to worry about allocation. It will occur the first time Singleton is accessed.
– Rafael Leão
Well, I made a more objective solution to the problem. I modified the class method that manages the database. Making the method receive the data and move to the input function. Then I prompt a Bdmanager object and send the insertData method with the properties(which are the values received from the webservice) as arguments. And the insertion works 100% within the method!
– Tiago Amaral