cleaner switch declarations

This commit is contained in:
2024-07-31 08:25:11 -05:00
committed by Celtic Minstrel
parent 9c1a5b98e1
commit e27165683c

View File

@@ -172,30 +172,24 @@ bool sync_prefs() {
if(object != nil){ if(object != nil){
prefs_recording << [pref UTF8String] << " = "; prefs_recording << [pref UTF8String] << " = ";
NSInteger type = [prefsToRecord[pref] integerValue]; NSInteger type = [prefsToRecord[pref] integerValue];
bool bvalue;
int ivalue;
double fvalue;
int count;
int c;
NSArray* arrayValue;
switch((int)type) { switch((int)type) {
case kBool: case kBool: {
bvalue = [standard boolForKey: pref]; bool bvalue = [standard boolForKey: pref];
if(bvalue == true){ if(bvalue == true){
prefs_recording << "true"; prefs_recording << "true";
}else{ }else{
prefs_recording << "false"; prefs_recording << "false";
} }
break; } break;
case kInt: case kInt: {
ivalue = (int)[standard integerForKey: pref]; int ivalue = (int)[standard integerForKey: pref];
prefs_recording << ivalue; prefs_recording << ivalue;
break; } break;
case kIArray: case kIArray: {
arrayValue = [standard arrayForKey: pref]; NSArray* arrayValue = [standard arrayForKey: pref];
prefs_recording << "["; prefs_recording << "[";
count = [arrayValue count]; int count = [arrayValue count];
c = 0; int c = 0;
for(id num in arrayValue){ for(id num in arrayValue){
prefs_recording << [num integerValue]; prefs_recording << [num integerValue];
if (c < count - 1) if (c < count - 1)
@@ -203,11 +197,11 @@ bool sync_prefs() {
++c; ++c;
} }
prefs_recording << "]"; prefs_recording << "]";
break; } break;
case kFloat: case kFloat: {
fvalue = (double)[standard doubleForKey: pref]; double fvalue = (double)[standard doubleForKey: pref];
prefs_recording << fvalue; prefs_recording << fvalue;
break; } break;
} }
prefs_recording << std::endl; prefs_recording << std::endl;
} }