Spaces in a NSURL with variables doesn't load

前端 未结 4 1709
暖寄归人
暖寄归人 2021-01-20 05:07

Hello everyone I have an objective-c dilema :P I am quite new to objective-c, and I have tried searching for an answer, but to no avail.

So, here is my situation. I

4条回答
  •  無奈伤痛
    2021-01-20 05:50

    If I understand you correctly, you're trying to generate a string with literal "%20"s embedded in it. The "%" character is special in format strings. If you want to insert a literal percent character, you need to escape it by putting two consecutive "%"s. Like

    [NSURL URLWithString:[baseURLStr stringByAppendingFormat:@"foo%%20bar"]];
    

    That would append "foo%20bar" to the end of the string.

提交回复
热议问题