码迷,mamicode.com
首页 > Web开发 > 详细

%3f URL --> '?'拼接引发的问题

时间:2016-07-03 21:37:14      阅读:901      评论:0      收藏:0      [点我收藏+]

标签:

 
 

 

[–]lyinstevemod 2 points 1 year ago 

If you‘re using Alamofire, you should really be submitting URL encoded parameters as a dictionary instead, because Alamofire handles serialization. You‘re doing more work than you should.

 

[–]xStory_Timex[S1 point 1 year ago 

I don‘t understand, can you explain more

 

[–]lyinstevemod 1 point 1 year ago 

So right now you‘re adding URL parameters, right? And you‘re serializing them into a string yourself.

You also said you‘re using Alamofire. Alamofire will actually take those arguments in a Dictionary as a parameter to the request() function. You don‘t need to -- and shouldn‘t -- manually create those strings.

Specifically just

?brand_id=\(id)

Instead, pass the parameters into the Alamofire request() function.

Alamofire.request(
   .GET,
   "/products",
   parameters: ["brand_id": id]
)
 
 
 
 
 
 
 

%3f URL --> '?'拼接引发的问题

标签:

原文地址:http://www.cnblogs.com/Jenaral/p/5638645.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!