草庐IT

Alamofire-SwiftyJSON

全部标签

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

swift - 如何在 alamofire 中设置请求超时?

我尝试使用NSURLSession,但现在我想使用Alamofire。 最佳答案 这种方法在swift3上对我有用letmanager:SessionManager={letconfig=URLSessionConfiguration.defaultconfig.timeoutIntervalForRequest=15config.timeoutIntervalForResource=15letmgr=Alamofire.SessionManager(configuration:config)returnmgr}()从https:/

ios - XCode 6.3 Alamofire.swift 文件崩溃

我是swift的新手。我在我的项目中使用Alamofire。另外,我安装了XCode6.3。然后,Alamofire.swift文件崩溃了。我修复了所有错误,但无法修复Alamofire.swift文件中的以下代码:publicfuncresponse(completionHandler:(NSURLRequest,NSHTTPURLResponse?,AnyObject?,NSError?)->Void)->Self{returnresponse(Request.responseDataSerializer(),completionHandler:completionHandler)

html - Alamofire Swift 获取html源码

我只想从一个简单的网站中检索html源。@IBActionfuncscan_func(sender:AnyObject){Alamofire.request(.GET,"http://www.example.com").response{request,response,data,errorinprint(request)print(response)print(data)}}我已经成功地添加了“AppTransportSecuritySettings”和“AllowArbitraryLoads”到info.plist以加载http内容。当我运行该代码时,我只会得到如下输出:XCODE

swift - Alamofire 编码 invalidURL

大家下午好,这里的新手正在尝试学习Swift/Alamofire。我已经为此苦苦挣扎了将近两天,并准备继续前进。我的URL似乎已更正,但在发出请求时出现错误。在查看Xcode调试日志时,看起来我的单引号在发送请求时被转义了。letowner:String="me@corp.local"funcgetDeploymentsByOwner(token:String,owner:String,success:@escaping(JSON)->Void,failure:@escaping(Error)->Void){letheaders=["Authorization":"Bearer\(to

swift - 如何正确安装 Alamofire SwiftyJSON 和 Alamofire-SwiftyJson

从我之前的问题中你可以看出,我在解析JSON数据时遇到了很多麻烦。经过几天的头痛之后,我认为最好的方法仍然是使用alamofire/swiftyjson。我还发现了alamofire-swiftyjson可以让一切都很好地协同工作。但我不确定如何将这三个“库”一起安装。我在我的项目中下载了整个Alamofire包,在我的项目中添加了SwiftyJson.swift,最后在我的项目中下载了Alamofire-SwiftyJson。但是当我用“responseSwiftyJSON”更改我的alamofire请求时,我收到一条错误消息““Request”没有成员名称“responseSwif