I’ve managed NSUserDefaults and stuck with writing the method to filter the SQL select according to settings in standardUserDefaults.
My app shows 6 continents and user has an option to disable some of them. In my SQL methods I currently trying to manage it this way:
if (![[NSUserDefaults standardUserDefaults] boolForKey:@"europe"])
{
sqlContinents="SELECT cont.continentID,cont.continentName,cont.continentImage\
FROM Continents as cont\
WHERE cont.continentID <> 1";
}
It will work if user will disable only europe, but what if he will disable more continents… so I can’t figure out how write code that will check which continents are disabled and omit them.
Of cause there’s an option to write many “ifs” like
if(![[NSUserDefaults standardUserDefaults] boolForKey:@”europe”] && ….&&……), but I would be very thankful if someone will show me how to implement such method in more smart and elegant way. Thank you in advance.
You can create a WHERE string that holds all conditions before the SQL sentence.