iphone - How to set RGB color from database -


i'm new in iphone development.i want set uilabel's background color database..i stored rgb color database.but i'm not getting background color.

const char *dbpath = [database_path utf8string]; sqlite3_stmt    *statement; [category_array removeallobjects]; [category_arrdictionary removeallobjects]; if (sqlite3_open(dbpath, &payer_db) == sqlite_ok) {     nsstring *querysql = [nsstring stringwithformat:@"select * expense_category"];      const char *query_stmt = [querysql utf8string];      if (sqlite3_prepare_v2(payer_db,query_stmt, -1, &statement, null) == sqlite_ok)     {         while (sqlite3_step(statement) == sqlite_row)         {             //              nslog(@"%i",sqlite_row);             nsmutablestring *category_id = [[nsmutablestring alloc]initwithutf8string:(const char *) sqlite3_column_text(statement, 0)];             nsmutablestring *category_name = [[nsmutablestring alloc]initwithutf8string:(const char *) sqlite3_column_text(statement, 1)];             nsmutablestring *category_image = [[nsmutablestring alloc]initwithutf8string:(const char *) sqlite3_column_text(statement, 2)];             nsmutablestring *category_color = [[nsmutablestring alloc]initwithutf8string:(const char *) sqlite3_column_text(statement, 3)];             nslog(@"%@",category_color);              [category_arrdictionary setobject:[nsmutablearray arraywithobjects:category_name,category_image,category_color,nil] forkey:category_id];             [category_array addobject:category_id];         }     }     else {         nslog(@"value updated");     }     sqlite3_finalize(statement);     sqlite3_close(payer_db); } 

}

- (uitableviewcell *)tableview:(uitableview *)tableview cellforrowatindexpath:(nsindexpath  *)indexpath  {     uilabel *lblcatcolor = [[uilabel alloc] initwithframe:cgrectmake(230,10, 70, 40)];     [lblcatcolor setbackgroundcolor:[[category_arrdictionary valueforkey:[category_array objectatindex:indexpath.row]] objectatindex:3]];     //lblcatcolor.text = [[category_arrdictionary valueforkey:[category_array objectatindex:indexpath.row]] objectatindex:3];     [cell.contentview addsubview:lblcatcolor];      return cell; } 

try this

nsstring *strflg=[[category_arrdictionary valueforkey:[category_array objectatindex:indexpath.row]] objectatindex:3]];  nsarray *colorarray=[strflg componentsseparatedbystring:@","]; float red; float green; float blue;  (int j=0;j<[colorarray count]; j++) {     if (j==0) {         red=[[colorarray objectatindex:j] floatvalue];     }     else if (j==1)     {         green=[[colorarray objectatindex:j] floatvalue];     }     else{         blue=[[colorarray objectatindex:j] floatvalue];     } }  [lblcatcolor setbackgroundcolor:[uicolor colorwithred:red/255.0f green:green/255.0f blue:blue/255.0f alpha:1.0]]; 

Comments

Popular posts from this blog

linux - xterm copying to CLIPBOARD using copy-selection causes automatic updating of CLIPBOARD upon mouse selection -

qt - Errors in generated MOC files for QT5 from cmake -