开发者

Can I copy NSURLRequest and reuse it?

开发者 https://www.devze.com 2023-03-18 12:41 出处:网络
I am using api with oauth2, and need to refresh the access token when it expires. So I want to resent 开发者_StackOverflow中文版the request after the request is refreshed. I am concerning whether the

I am using api with oauth2, and need to refresh the access token when it expires. So I want to resent 开发者_StackOverflow中文版the request after the request is refreshed. I am concerning whether the NSURLConnection will change the http request object. Thanks in advance!


Have you checked out the URL loading guide? It has this in a box in the text:

When a client application initiates a connection or download using an instance of NSMutableURLRequest, a deep copy is made of the request. Changes made to the initiating request have no effect once a download has been initialized.

So you can reuse your request as much as you like without fear of modification. NSURLConnection works with a copy of it.

0

精彩评论

暂无评论...
验证码 换一张
取 消