草庐IT

post_type

全部标签

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

Swift 3 Oauth2 Imgur 刷新键 - 错误 400 "Invalid grant_type parameter or parameter missing"

我在使用Swift/NSMutableURLRequest调用ImgurAPI的/oauth2/token端点时遇到问题,也许这实际上只是我以错误的方式设置了请求,因为我对NSMutableURLRequest没有太多经验。场景:用户已经验证了我的应用程序,他可以将照片发布到他的Imgur帐户。问题:Imgur要求28天后重新认证。这就是为什么在对应用程序进行身份验证后,您会得到一个(临时的;28天)access_token和一个长期的refresh_token,您可以在28天后使用它来获得一个新的访问token。我按照API调用来检索新的access_token但总是收到错误:“无效

json - 从服务器端 swift perfect 应用程序向另一个 http api rest 应用程序发送 json post 请求

我想创建一个Swift服务器端Perfect应用程序,它通过发布一个JSON格式的查询并接收JSON来调用另一个RESTAPI,但我对Perfect和服务器端Swift总体来说还很陌生,所以我不确定该怎么做它。我知道如何从SwiftiOS客户端应用程序执行此操作,但不确定如何从Perfect执行此操作。有人可以帮我吗?我在Perfect网站上看到了有关如何使用get执行此操作的示例,但我要发布到的服务器只接受JSON帖子。如果有人知道我可以看看的例子,将不胜感激。提前致谢。 最佳答案 我在perfectslackchannel上询问

swift - 泛型类型错误 : Cannot explicitly specialise a generic type

我正在尝试在RequestManager中创建一个通用函数通过ServiceManager将服务器接收到的JSON转换为指定类型.这是我的代码:请求管理器:typealiasResultResponseManager=(_data:AnyObject?,_error:ErrorPortage?)->VoidtypealiasSuccessResponseManager=(_success:Bool,_error:ErrorPortage?)->VoidtypealiasobjectBlock=(_object:T?,_error:ErrorPortage?)->Voidextensio

ios - 错误 : Invalid conversion from throwing function of type '(_) throws -> ()' to non-throwing function type '(DataSnapshot) -> Void'

这是我的代码:funcloadData(){ref.child(currentUserID!).observe(.childAdded){(snapshot)inletsnapshotValue=try?snapshot.valueas?[String:AnyObject]ifletitem=tryTableViewModel(id:snapshot.key,likeLabel:self.likeLabel,playLabelString:self.playLabelString,json:snapshotValue){self.items.append(item)}self.tabl

swift 4 : Cannot call value of non-function type '[Self.Element.Type]' when instantiating associated type array

我在这篇文章(https://www.uraimo.com/2016/01/06/10-Swift-One-Liners-To-Impress-Your-Friends/)中对Xcode9beta2Swift4做了一些练习,当时我在执行第1项时遇到错误。6:extensionSequence{typealiasElement=Self.Iterator.ElementfuncpartitionBy(fu:(Element)->Bool)->([Element],[Element]){varfirst=[Element]()varsecond=[Element]()forelinself

Maven工程 报 Diamond types are not supported at language level '5'

原文链接:https://blog.csdn.net/dongzhensong/article/details/88799477主要是参考了上面的做法就是目前使用的方法超过了选择的languagelevel的用法。我主要是在Modules–Languagelevel中解决的即在projectsettings中的modules里languagelevel要选择8以上。但是还有一个是要查看IDEA编辑器的JDK版本否则在run的时候会提示:Error:java:Compilationfailed:internaljavacompilererror所以需要在File-->Settings-->Bui

ios - 无法将 UIImage 编码为 POST 请求的数据

我正在将UIImage转换为数据以通过httpPOST请求发送到服务器。在为请求准备正文时,函数createBody被调用,传递给该函数的图像数据是UIImageJPEGRepresentation(image,0.7)!staticfunccreateBody(parameters:[String:String],boundary:String,data:Data,mimeType:String,filename:String)->Data{letbody=NSMutableData()letboundaryPrefix="--\(boundary)\r\n"for(key,valu

swift - 如何解决 "Argument type ' CustomStruct' does not conform to expected type 'Sequence' "

我试图使用下面的代码来洗牌一个由名为Card的简单自定义结构组成的数组。,我在cards.remove(at:randomIndex)处收到错误:Error:Argumenttype'Card'doesnotconformtoexpectedtype'Sequence'代码如下:varcards=[Card]()//declarethearrayvarshuffledCards=[Card]()for_incards.indices{letrandomIndex=Int(arc4random_uniform(UInt32(cards.count)))shuffledCards+=car

swift - 检查 Any.Type 是否符合 Swift 中的协议(protocol)

我想检查Any.Type的给定值是否符合Swift中的协议(protocol)。似乎可以通过调用class_conformsToProtocol()检查基于@objc的协议(protocol),但我不知道如何使用纯swift协议(protocol)检查它。//ObjC@objcprotocolMyObjcProtocol{}classMyObjcClass:NSObject,MyObjcProtocol{}class_conformsToProtocol(MyObjcClass.self,MyObjcProtocol.self)//true//SwiftprotocolMySwiftP