writing % in NSString writing % in NSString sqlite sqlite

writing % in NSString


To use % in a format string you should use %% instead of \%.


Use this format %% instead of /%.And try to use like this

  str1=[NSString stringWithFormat:@" ri.name like  %% %@ %%",[array objectAtIndex:i]];


Talking about SQL, one thing that the others aren't saying is that you are putting spaces before and after the %characters,

What the other answers will print is something like this:

@" ri.name like  % example %"

And that will look for subStrings in your table with those spaces after and before.

Maybe what you are looking for is:

str1 = [NSString stringWithFormat:@" ri.name like ' %%%@%%'", [array objectAtIndex:i]];

Which will print:

@" ri.name like  %example%"