ios - Have string represent integer value - Obj C -
i have situation there either 4 options or less. options a,b,c,d (or a,c or a,c,d...ect). , each option associated integer value 0 - 4000. , if 4 options a,b,c,d available want represent 0-999, b represent 1000-1999...ect. if options a,c,d want = 0-999, c = 1000-2999 & d = 3000-4000, , on different types of options, can input values depending on options available (not spilt evenly). bunch of if statements seems impractical.
if (a & b & c & d) { = 0-999; b = 1000-1999; ... } else if(a & c & d) { ... } //and on , on lot of combinations
there must better way set up, , more efficient bunch of if statements, how go doing this?
thanks in advance.
keep options in array,
nsarray *options=@[@"a",@"b",@"c"]; int i=-1; (nsstring *s in options) { // assign options value i++; // s = i+999 stuff assign value option. i=i+999; }
if want do.
Comments
Post a Comment