Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

escape % in objective c

Tags:

objective-c

I want to make an sql statement -

sqlStatement = [NSString stringWithFormat:@"SELECT * FROM movies where title like '%%@%'",searchKeyword];

But sqlStatement is becoming -

"SELECT * FROM movies where title like '%@'"

I want to make it

"SELECT * FROM movies where title like '%searchKeyword%'"

How can I escape the "%" character?

Thanks

like image 619
Saurabh Avatar asked Jun 15 '10 12:06

Saurabh


1 Answers

Try :

sqlStatement = [NSString stringWithFormat:@"SELECT * FROM movies where title like '%%%@%%'",searchKeyword];

"%%" is the way of printing the '%' character.

like image 146
Acibi Avatar answered Nov 02 '22 14:11

Acibi