草庐IT

AlamoFire

全部标签

ios - Alamofire 获取请求和 JSON 响应

我正在尝试使用YodaAPI并使用Alamofire发送请求swift框架。我知道API正常工作,因为我已经多次使用我的MashapeAPIkey测试端点。我还可以看到正在发送请求(在我的应用程序下的Mashape主页)。但是我的JSON响应始终是nil。funchandleRequest(words:String){varsaying=words.stringByReplacingOccurrencesOfString("",withString:"+");saying="?sentence="+saying;leturl=NSURL(string:(baseURL+saying))

ios - Alamofire 参数 - NSDictionary 不可转换为 [String : AnyObject]

所以我正在尝试使用Alamofire发送一个json对象作为参数。我想我已经遵循了他们文档中的示例,但是我在方法调用中遇到了这个错误。@IBActionfuncsaveButton(sender:AnyObject){varurl="http://b857aaa4.ngrok.io/recruit"letparameters=["_id":firstNameTextField.text,"alt_email":"","forename":firstNameTextField.text,"phone":recruteePhone.text,"recruiter":["comments":

swift - 后台请求不执行 Alamofire Swift

我正在尝试在后台进行调用,例如POST,GET在didReceiveRemoteNotification方法中更精确,因为它们在推送通知到达时开始工作。我的问题是,在我打开应用程序之前,所有Alamofire.request都不会在后台模式下调用。我现在有我试图打开一个session,但它不会使请求工作。这些是我想在后台执行的(手机在后台)Alamofire.Manager(configuration:configuration).request(.GET,url,parameters:nil).responseJSON{(_,_,JSON,_)in//println(JSON)pri

ios - 如何使用 Swift 在 iOS 上通过异步操作同步运行两个函数

让我们提出这个场景具有异步网络操作的方法funcasyncMethodA()->String?{result:String?Alamofire.manager.request(.POST,"https://www.apiweb.com/apimethod",parameters:parameters,encoding:.JSON).response{(request,response,rawdata,error)inif(response?.statusCode==200){//DOSOMEHEAVYLIFTING}}returnresult//string}另一种异步网络操作的方法f

使用Alamofire在字典中解析JSON对象

嗨,这是我的JSON响应,如何在数组中存储“数据”参数值。我使用的是Alamofire4和Swift3。我希望以阵列格式使用此此内容,以便在TableView中加载内容。Optional({"current_page"=2;data=({"address_location"="placeofcourse";"category_id"=1;"course_id"=122;"course_title"=title;description="dessriptionaboutthecourse";favorited=0;"from_date"="2017-02-16";image="";lattitu

html - 使用 Alamofire 的谷歌搜索失败(iOS、Swift、JSON、HTML)

求助!几个月来,我一直在尝试在我的Swift应用程序上执行简单的Google搜索,但我的头撞墙已经过去了!我已经尝试使用ALAMOFIRE和常规URLRequest,但由于结果似乎只是HTML格式,我似乎无法正确解析结果。即使您查看HTML格式,代码也是针对网页的,并且不包括搜索结果。我希望将搜索结果放入简单词典中。这是我的代码:letgoogleUrl:String="https://cse.google.com/cse/publicurl?&output=json&cx=:&q=q=+normal+search"//TryingwithAlamoFire:Alamofire.req

html - 使用 Alamofire 的谷歌搜索失败(iOS、Swift、JSON、HTML)

求助!几个月来,我一直在尝试在我的Swift应用程序上执行简单的Google搜索,但我的头撞墙已经过去了!我已经尝试使用ALAMOFIRE和常规URLRequest,但由于结果似乎只是HTML格式,我似乎无法正确解析结果。即使您查看HTML格式,代码也是针对网页的,并且不包括搜索结果。我希望将搜索结果放入简单词典中。这是我的代码:letgoogleUrl:String="https://cse.google.com/cse/publicurl?&output=json&cx=:&q=q=+normal+search"//TryingwithAlamoFire:Alamofire.req

ios - 如何使用 Alamofire 4 在 Swift 3 中发送带有参数和主体的 JSON 数据的 POST 请求?

在下面添加了Postmanapiurl。当前代码:letbaseUrl="abc.com/search/"letparam=["page":"1","size":"5","sortBy":"profile_locality"]letheaders=["Content-Type":"application/json"]Alamofire.SessionManager.default.request("\(baseUrl)field",method:.post,parameters:param,encoding:JSONEncoding.default,headers:headers).r

ios - 如何使用 Alamofire 4 在 Swift 3 中发送带有参数和主体的 JSON 数据的 POST 请求?

在下面添加了Postmanapiurl。当前代码:letbaseUrl="abc.com/search/"letparam=["page":"1","size":"5","sortBy":"profile_locality"]letheaders=["Content-Type":"application/json"]Alamofire.SessionManager.default.request("\(baseUrl)field",method:.post,parameters:param,encoding:JSONEncoding.default,headers:headers).r

ios - 异构集合文字只能推断为 '[String : Any]' ;如果这是有意的,请添加显式类型注释

我有一个像这样的POST正文参数:{"id":0,"name":"string","contactInfo":"string","message":"string"}因此,由于我使用Alamofire来发布参数,因此我将这样描述发布正文字典:letbody=["id":userID,"name":userName,"contactInfo":contactInfo,"message":message]classfuncpostUserFeedback(userID:Int,userName:String,contactInfo:String,message:String,complet