草庐IT

Alamofire-SwiftyJSON

全部标签

swift - xcode8 Alamofire 4更新错误 "use of undeclared type Response"

更新到Xcode8和Alamofire4后,我在代码“ResponseclassFetchData{staticfuncget(_type:T.Type,success:@escaping()->Void,fail:@escaping(_error:NSError)->Void)->VoidwhereT:Mappable,T:Meta{Alamofire.request(type.url(),method:.get).responseArray{(response:Response)in//.responseArray{(response:DataResponse)inswitchre

ios - Alamofire 的 CompletionHandler

我正在尝试返回responseJSONstaticfuncgetAllPersons(completionhandler:@escaping(Any)->()){letURL=baseURL+"api/person"Alamofire.request(URL).responseJSON{responseincompletionhandler(response.result.valueasAny)}}但如果我尝试将responseJSON存储在“res”中,它将不起作用:varres:Any=""PersonResource.getAllPersons{(result)inres=res

swift - postman 和 alamofire 之间的响应时间

我目前正在开发一个Swift3应用程序,我对应用程序的响应时间感到遗憾......postman,我的请求在200毫秒内响应,但在应用程序中,感觉从请求到响应之间的时间超过10秒...这是一个请求花费太多时间的例子:classfuncgetFriendPage(page:Int,callback:@escaping(Bool,JSON)->Void){leturl=NetworkManager.getUrl()+"api/v1/challenges/friends?page="+String(page)letparams=[:]as[String:Any]?Alamofire.requ

ios - 等到 alamofire 完成获取请求和创建对象

这个问题在这里已经有了答案:SwiftFunctiontoparseJSONandreturnaarrayofdictionaries(1个回答)关闭5年前。我遇到了一个问题,就是要等到一个对象制作完成,然后我想更新我的UI。如果我运行这个函数,它会立即得到超出索引的错误,因为它试图从第一个对象中获取一些文本,当它不存在时......任何人都可以帮助我吗?funcgetMovieData(activeGenreLink:String){//self.posterLoading.startAnimating()Alamofire.request(activeGenreLink).resp

swift - 错误 401 : Alamofire/Swift 3

此代码以前有效,但经过多次解决后突然停止并返回错误401。Alamofire.request(WebServices.URLS().TabDataURL,method:.post,parameters:reqParams).validate().responseJSON{responseinletstatusCode=(response.response?.statusCode)//GetHTTPstatuscodeguardresponse.result.isSuccess,letvalue=response.result.valueelse{//FIXME:youneedtohan

ios - Alamofire 无法禁用缓存

我无法让Alamofire或iOS停止缓存:Alamofire.SessionManager.default.session.configuration.requestCachePolicy=.reloadIgnoringLocalCacheData或URLCache.shared.removeAllCachedResponses()我需要为所有请求禁用它吗?还试过:letconfiguration=URLSessionConfiguration.defaultconfiguration.urlCache=nilletmanager=Alamofire.SessionManager(c

ios - Alamofire .dowload 占用大量内存(ios,swift)

我使用alamofire框架从服务器下载图像。我与Alamofire.download一起工作。每个图像的大小都在1MB+-以上,但每次请求内存后都会增加很多。下载4张图像后,使用的内存超过171MB,之后每张图像超过35MB。下载代码为:Alamofire.download(mainReguest,to:self.destination).downloadProgress{progressinself.progressView.progress=Float(progress.fractionCompleted)}.response{responseinifresponse.error

ios - 如何在同一个函数中只有 1 个完成处理程序用于 2 个 Alamofire 请求

我有一个函数,里面有2个Alamofire请求和一个完成处理程序。一旦我的两个请求都完成了从服务器下载数据,我想重新加载我的collectionView。我在函数中有一个完成处理程序,但它被调用了两次,这导致我的collectionView重新加载两次,我只想重新加载一次。有什么办法可以做到吗?非常感谢!funcgetFeedVideos(completion:@escaping(_completedDownloadVideo:Bool)->()){Alamofire.request(youTubeUrl,method:.get,parameters:["part":"snippet"

ios - 带模型的 SwiftyJson 嵌套数组

如何使用SwiftyJSON和第二组嵌套对象数组创建数据模型?我能够很好地解析和存储顶级对象,但不能解析和存储内部对象。特别是noteimages,我似乎无法弄清楚。下面是api结果,下面是我尝试这样做的方式,尽管不太正确。[{"id":1,"title":"sometitle","details":"herearesomedetails","userId":1,"hidden":false,"createdAt":"2018-02-14T07:02:33.000Z","updatedAt":"2018-02-14T07:02:33.000Z","contactId":1,"notei

ios - Alamofire 数据响应时 Swift 4 Timer

我有一个Alamofire函数,就像当数据来时将数据插入GlobalNsDictionaryCommon.Customers函数是staticfuncPostAlomofire(format:RequestFormat){letloginParam:[String:Any]=["searchTerm":format.Name,"pageSize":format.PageSize,"pageNumber":format.PageNumber,"deviceId":format.DeviceId]print(loginParam)Alamofire.request("http://111.