ios - cycle for insert array -


please need help, have following code:

nsstring* string = [[nsstring alloc] initwithdata:responsedata encoding:nsutf8stringencoding]; nsarray* params= [string componentsseparatedbystring:@"\\"];  lugar  = params[0]; texto1 = params[1]; texto2 = params[2]; texto3 = params[3];  nsstring *query; query =[nsstring stringwithformat:@"insert contenido values(null,'%@','%@','%@','%@')", lugar,texto1,texto2,texto3];   // execute query. [self.dbmanager executequery:query];  // if query executed pop view controller. if (self.dbmanager.affectedrows != 0) {     nslog(@"query executed successfully. affected rows = %d", self.dbmanager.affectedrows); } 

and receive string text follows: 34 \ field1 \ dfr23 \ \ 35 \ field2 \ dfr24 \ \ 36 \ field3 \ dfr25 \ bad

my code separates first 4 spaces separated \ need inserting cycle spaces in array, please me?

you can use stringbyappendingstring method can connect 1 string another.

do this:

long numberofspaces = [params count];  nsstring querystring = @"@"insert contenido values(null"; (int = 0; < numberofspaces; i++) {      nsstring *nextparam =  [nsstring stringwithformat:@",//'%@",params[i]];      querystring = [querystring stringbyappendingstring:nextparam; } 

Comments

Popular posts from this blog

c++ - No viable overloaded operator for references a map -

java - Custom OutputStreamAppender not run: LOGBACK: No context given for <MYAPPENDER> -

java - Cannot secure connection using TLS -