escape % in objective c

后端 未结 1 1547
眼角桃花
眼角桃花 2021-01-11 17:12

I want to make an sql statement -

sqlStatement = [NSString stringWithFormat:@\"SELECT * FROM movies where title like \'%%@%\'\",searchKeyword];
1条回答
  •  时光说笑
    2021-01-11 17:28

    Try :

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

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

    0 讨论(0)
提交回复
热议问题