Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Best way to store a large array of boolean variables?

I am working on a code which requires me to store 60*4 boolean values, the titles for these values are being stored in a plist. I require to manipulate the boolean values at runtime and couldn't find a way to update the plist file easily..also using sqlite database for storing the boolean values becomes hectic for such large amount of data...Is there any simple way through which I can store and retrieve these values easily both at runtime and after the application starts?

like image 545
Snehal Avatar asked Dec 31 '22 04:12

Snehal


2 Answers

I don't mean to be a heretic, but there's a simple rule for cases like this: premature optimization is the root of all evil.

60*4 is only 240 booleans. Even if you somehow manage to store them in the worst possible way and take 1k per boolean, that's still only 240k. As long as that's storage rather than RAM, who cares? Why not start with the simplest possible way and fix it when something comes to you later? SQLite would be perfectly fine for this.

If you're close to shipping and have identified this as a problem, by all means ignore this answer. :)

like image 137
Steven Fisher Avatar answered Jan 11 '23 10:01

Steven Fisher


While its going to be much easier to use NSArray or NSMutableArray as mentioned above, you could look at using the standard C++ vector class. AFAIK this is very space-efficient wrt. the allocation of memory.

like image 25
corvi42 Avatar answered Jan 11 '23 11:01

corvi42