I have a table view with days from Monday to Sunday. I can use a bitmask to represent select/unselect all of them.
For example, if I select all of them, I will have 1111111
in binary or 127 in decimal. I found an enums example but can't recognize how to get an Integer from enums and then convert that number into selected days again if needed.
Let's say I selected all days in table, then I leave that table and reopen it one more time. So in my data I have 127 which represent all days that I selected (it can be 2 or 3 days selected for example). So I want to check mark those days as selected. But I have just a decimal.
What is the better way to do it?
And how to write switch
That should be kind like this I guess:
func markDaysAsSelctedWith(number: Int)
{
switch (number) {
case Days.Monday
case Days.Sunday
}
Here is my problem: if I use the number 12 to represent the selected days Wednesday and Thursday:
M = 1,
Tu = 2,
W = 4,
Th = 8,
F = 16,
Sa = 32,
Su = 64
then switch will not work...