首页 > Web开发 > 详细

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

时间:2016-07-03 21:35:41      阅读:296      评论: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
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!