草庐IT

friend_request

全部标签

swift - 访问 `Request` 主体参数

我正在尝试使用以下代码创建对第三方API的请求链:importVaporfinalclassAPIController:RouteCollection{privateletbaseULR="..."funcboot(router:Router)throws{router.post("login",use:validate)}funcvalidate(_req:Request)throws->Future{//GetthephonenumberoftheuserletphoneNumber=tryreq.content.syncGet(String.self,at:"phone_numb

ios - Swift 项目中的 AFNetorking -- "Error: Request failed: unacceptable content-type: text/html"

我正在将带有CocoaPods的AFNetworking实现到一个Swift项目中。我习惯用Ruby编程,而我对iOS开发还很陌生。Cocoapods很难在我的项目中正常工作,但我现在可以成功访问AFNetworking库。我想做的是用POST命中一个表单并得到一个我可以解析的“text/html”响应,这样我就可以判断它是否保存了。这本身不是API,而是由InfusionSoft生成的表单。用户将输入一个电子邮件地址,我会将其发送到API进行存储。这是我使用的代码:letmanager=AFHTTPRequestOperationManager()varparameters=["in

ios - swift Alamofire : How to validate both a valid request and a valid response code

我们有这个Alamofire错误处理:Alamofire.request(.GET,getUrl("mystuff")).responseData{responseinguardresponse.result.error==nilelse{//Handleerror}}如果无法访问服务器或证书无效等,它会很好地工作。但是如果可以访问服务器但返回404/etc响应代码,则不会触发此错误处理代码。如何将对此用例的支持折叠到此代码中? 最佳答案 response的result属性包含代码,如果它不是nil。否则,您可以获得状态代码。ifl

swift - Alamofire:类型 'Request' 的值没有成员 responseImage?

我正在做一个项目,使用Alamofire+AlamofireImage。我刚刚通过CocoaPods安装了AlamofireImage,但出现了这个错误:Valueoftype'Request'hasnomember'responseImage'对于行:Alamofire.request(.GET,locationURL).responseImage{responseinifletimage=response.result.value{//morecode在所有其他项目中工作正常,Podfile安装行也完全相同。 最佳答案 不确定整

ios - Alamofire 4.0.0 : [String:String] is not convertible to [String : Any] & Request is ambiguous without more context

我正在将Alamofire更新到4.0.0Beta1并将XCode8更新到Beta6。首先,我得到了[String:String]isnotconvertibleto[String:Any]错误代码letparameter=["scope":"\(scope)","client":"\(clientId)"]Alamofire.request(link,withMethod:.POST,parameters:parameter,encoding:.json).responseJSON在我更改后将[String:Any]添加到参数中,错误消失但产生了新错误:Expressiontype'

swift 4 : Formatting number's into friendly K's

目前正在开发一个对我来说非常有用的简单功能..例如:如果我有1000,它会打印出1.0K,或者1,000,000它将是1M,直到这里一切正常,Whatifiwantedtoturn1,000,000,000into1B?我尝试了以下->funcformatPoints(from:Int)->String{letnumber=Double(from)letthousand=number/1000letmillion=number/1000000letbillion=number/1000000000ifmillion>=1.0{return"\(round(million*10)/10)

ios - CCAvenue: "Error!!! in decrypting application request"

我正在尝试将CCAvenue支付网关集成到我使用swift4开发的iOS应用程序中。我得到了"Error!!!Problemindecryptingapplicationrequest"我已检查给出的答案:https://stackoverflow.com/a/37327122/3548469但我的案子没有运气。这是我从文档中尝试过的privatefuncgettingRsaKey(completion:@escaping(_success:Bool,_object:AnyObject?)->()){letserialQueue=DispatchQueue(label:"serialQ

ios - 收到 MailChimp 错误 "Your request did not include an API key.",即使使用 Alamofire 包含 API key

我正在使用Alamofire向MailChimp发送请求以将用户添加到列表MailChimp的文档说:Thereare2authenticationmethodsfortheAPI:HTTPBasicauthenticationandOAuth2.TheeasiestwaytoauthenticateisusingHTTPBasicauthentication.EnteranystringasyourusernameandsupplyyourAPIKeyasthepassword.我为Alamofire写的请求:letparams:[String:AnyObject]=["email_

swift - 错误 : Extra parameter in request i used Swift 4. 为什么我必须传递类型为 [String : Any]? 的参数

Alamofire.request(APPURL.GetAccounts,method:.post,parameters:transactionData,encoding:JSONEncoding.default,headers:nil).responseJSON{responseDatain}我的问题是限制我只能通过[String:Any]类型的字典的原因是什么?完整代码:classfuncgetAccounts(transactionData:[String:Any]?,withCompletionHandler:@escaping(_response:AnyObject?)->(

ios - MKMapView:如何复制在 Apple 的 'bounce-zoom' 应用程序中看到的 'Find my iPhone/Friends'?

背景MKMapView附带了几种方法,可让您设置可见map矩形(或区域、坐标跨度等)。这些方法有一个animated参数,当设置为true时,将使用大约0.3秒的线性动画来为变化设置动画。问题虽然这很好,但我想复制Apple在他们的FindmyFriends和FindmyiPhone应用程序中使用的动画,当点击map时。如果您自己尝试一下,您会发现带有非线性曲线的动画速度更快(大约0.15秒)。现在,我们称其为“弹跳-缩放”过渡。我想复制非线性动画曲线和自定义动画持续时间。在UIView的animateWithSpring...方法中包装map更新似乎不起作用(当然我可能做错了)。非常