Objective-C: How to add query parameter to NSURL?

前端 未结 8 1845
猫巷女王i
猫巷女王i 2020-12-23 18:45

Let\'s say I have an NSURL? Whether or not it already has an empty query string, how do I add one or more parameters to the query of the NSUR

8条回答
  •  遥遥无期
    2020-12-23 19:36

    NSURL is not mutable so you cannot implement this functionality directly based on NSURL. Instead you will have to obtain the string representation of the URL, append your parameters to that and then create a new NSURL.

    This does not sound like a good solution. Unless there is a good reason, it is better to work with strings until the last moment and only create an NSURL when you have your fully formed request.

提交回复
热议问题