草庐IT

Alamofire4

全部标签

ios - 如何在 iOS Widget 中使用 Alamofire

在我的Widgets目标中实现Alamofire时,它​​说例如“使用未解析的标识符‘Alamofire’。我需要以某种方式将我的Widget添加为Alamofire项目的目标。我该如何实现?一些示例代码://Parametersletparameters:[String:Any]=["id":id,"state":true]Alamofire.request("https://someurl.com"method:.put,parameters:parameters,encoding:JSONEncoding.default).responseJSON{responsein//Che

Swift 4 + Alamofire 可解码 Json URL 格式

我有一个无法使用Alamofire解码的JSON格式。这是我的json:"data":[{"id":37,"status":"A\u00e7\u0131k","department":"Muhasebe","title":"Y\u00f6netimPanelindenDeneme4-MailKontrol","message":"Y\u00f6netimPanelindenDeneme4-MailKontrol","file":null,"created_at":{"date":"2018-01-1301:59:49.000000","timezone_type":3,"timezon

Swift:如何使用库:Alamofire-SwiftyJSON

我在尝试让这个库Alamofire-SwiftyJSON(https://github.com/SwiftyJSON/Alamofire-SwiftyJSON)工作时遇到问题。我创建了一个新项目并下载了Alamofire-SwiftyJSON库并将所有内容拖到我的项目导航区域中。但是当我进入ViewController并添加:importAlamofireSwiftyJSON我得到错误:没有这样的模块导入AlamofireSwiftyJSON谁能告诉我如何手动添加这个项目。理想情况下一步一步,这样我就可以让这段代码工作:Alamofire.request(.GET,"http://ht

swift - cURL 与 Alamofire - Swift - 多部分/表单数据

首先,如果这个问题很愚蠢,我很抱歉,但我对这个东西还很陌生。我尝试了不同的方法来创建与Alamofire的cURL请求的快速等价物,但我不知道如何将图像作为multipart/form-data发送到API。curl-XPOST-F"file=@/Users/nicolas/sample.png"-F"mode=document_photo"https://api.idolondemand.com/1/api/sync/ocrdocument/v1-F"apikey=xxx-xxx-xxx-xxx-xxx"我认为目前的代码对于这种类型的请求来说是非常错误的,但我仍然会为您发布它:fun

ios - 使用 URLEncoding 为 Alamofire 帖子编码 Swift 数组

重新发布,因为我搞砸了之前的编码类型......我需要使用URLEncoding将数组发送到带有Alamofire的服务器。但是,它需要以某种方式编码,以便Alamofire正确发送。这是我的代码:letparameters:[String:Any]=["names":["bob","fred"]]Alamofire.request(urlString,method:.post,parameters:parameters,encoding:URLEncoding.default).responseJSON{responsein//etc}然而,参数永远不会被编码,只是作为nil发送。我

ios - 使用 Alamofire 和 Swift 4 上传图片时出现问题

我正在尝试通过我的应用程序将图片从图库上传到服务器。这是我的代码:funcimagePickerController(_picker:UIImagePickerController,didFinishPickingMediaWithInfoinfo:[String:Any]){ifletuserID:String=userDefaults.string(forKey:"userID"){letURL:String="HERE_IS_URL"letchosenImage=info[UIImagePickerControllerOriginalImage]as!UIImageletimag

Swift Alamofire 响应状态码

如何从Alamofireresponse获取状态码?在最新版本中,我可以使用validate,但我需要检查状态码是什么。代码:Alamofire.request(.GET,"http://example.com/url").responseJSON{responsein} 最佳答案 这有效(在@MirzaDelic指出我的错误之后):Alamofire.request(.get,"http://www.google.com").responseJSON{responseinifresponse.response.statusCode

ios - swift ,Alamofire.framework : No such file or directory

我正在开发一个ios应用程序,一切都很顺利,然后突然出现这个错误error:/Users/himanshututeja/Library/Developer/Xcode/DerivedData/xxxxx-ebvzljjfvuvqcubfgvneealjrdrg/Build/Products/Debug-iphoneos/Alamofire.framework:Nosuchfileordirectory我删除了xcode的派生数据文件夹,仍然没有帮助。有谁知道我遇到这个问题的原因? 最佳答案 如果您使用的是cocoapods,那么您应

swift - 使用 Alamofire 在 Swift 中将 JSON 转换为字典

我想使用Alamofire在Swift中将JSON数据转换为字典。我正在尝试ifletdict=response.result.valueas?Dictionary{...},不幸的是它不起作用。有什么建议么?提前致谢。这是打印我的response.result.value的示例Optional(({category=category1;description=description1;name=sth1;id=1;price="213";type=type1;},{category=category2;description=description2;name=sth2;id=2;p

swift - 我是否需要明确说明我想在 xcode 9、swift 4 中使用 cocoapods 安装哪个版本的 alamofire

有这个教程re:alamofirehttps://www.raywenderlich.com/147086/alamofire-tutorial-getting-started-2并且在其中要安装的pod被声明为“Alamofire”,“~>4.2.0”我需要指定版本4.2.0还是我可以将它声明为pod'Alamofire'?我去了cocoapods上的Alamfoire页面,但我实际上找不到最新的稳定版本是什么,尽管我确定它在某处。还有这篇文章:alamofirenotworkingwithxcode9/swift4Xcode9failstobuildSwift4projectwit