草庐IT

以错误类型作为参数的 iOS AWS 协议(protocol)方法导致协议(protocol)不符合

我正在使用AWSMobileHub为我用Swift编写的iOS应用程序实现登录。直到本周,它都运行良好,但更新到Xcode9.1导致出现几个构建错误。我还有2个错误。两者都涉及专门调用协议(protocol);“AWSSignInDelegate”和“AWSCognitoIdentityPasswordAuthentication”。extensionSignInVC:AWSSignInDelegate{funconLogin(signInProvider:AWSSignInProvider,result:Any?,error:Error?){//Code}}extensionSign

ios - 类型 'Any' 不符合协议(protocol) 'Equatable' 尝试符合可等式泛型集时

我正在尝试创建一个支持一组类型(Int、Float、可能是字符串,有时可能是Vec4矩阵)的基本结构。我已经构建了一个基本结构并将其符合Hashable,将类型设置为Equatable,但现在我需要在Set中使用这个新结构。这一行:structAdjustmentSet:Set>我声明Set的结构的地方是抛出Type'Any'doesnotconformtoprotocol'Equatable'这当然是显而易见的,但我不知道如何在这里实际定义一个有效的类型(我尝试了T:Equatable、Equatable,但没有任何效果)。structBaseAdjustment:Hashable{

ios - 类型 'String?' 不符合协议(protocol) '_CollectionType'

vardesc=item.itemDescriptionletregex:NSRegularExpression=NSRegularExpression(pattern:"",options:NSRegularExpressionOptions.CaseInsensitive,error:nil)!letrange=NSMakeRange(0,countElements(desc))lethtmlLessString:String=regex.stringByReplacingMatchesInString(desc,options:NSMatchingOptions.allZeros

swift - 为什么子协议(protocol)不符合其父协议(protocol)?

这个问题在这里已经有了答案:Whycan'taget-onlypropertyrequirementinaprotocolbesatisfiedbyapropertywhichconforms?(3个答案)关闭3年前。我有符合协议(protocol)的结构,但使用的是派生协议(protocol),而不是直接使用其父协议(protocol):protocolA{}protocolB:A{}protocolC{varproperty:A{get}}structFoo:C{letproperty:A}structBar:C{letproperty:B}//Error:Type'Bar'doe

swift - 什么样的 URL 不符合 RFC 3986 但符合 RFC 1808、RFC 1738 和 RFC 2732?

URLComponents.init(url:resolvingAgainstBaseURL:)的文档说:ReturnstheinitializedURLcomponentsobject,orniliftheURLcouldnotbeparsed.知道:SwiftURL/NSURL适用于基于RFC1808、RFC1738和RFC2732的URL:https://developer.apple.com/documentation/foundation/nsurlSwiftURLComponents/NSURLComponents适用于基于RFC3986的URL:https://devel

ios - 类型 UITableView 不符合协议(protocol) IntervalType

我升级到xcode6beta5。它出现了一个新错误:TypeUITableViewdoesnotconformtoprotocolIntervalType.funcnumberOfSectionsInTableView(tableView:UITableView!)->Int{switchtableView{casetableViewPopular://ERRORprintln("tableViewPopular")return1casetableViewSearch://ERRORprint("tableViewSearch")println("sceneKeys.count-->\

ios - Swift 2.0 类型 '()' 不符合协议(protocol)

我在viewcontroller中使用相机时实现了这个方法letcaptureDevice=AVCaptureDevice.defaultDeviceWithMediaType(AVMediaTypeVideo)//...codeifletdevice=captureDevice{do{if(trydevice.lockForConfiguration()){device.focusPointOfInterest=focusPointdevice.focusMode=AVCaptureFocusMode.ContinuousAutoFocusdevice.exposurePointOf

ios - 类不符合协议(protocol)

这是我的协议(protocol):protocolLiveTableViewCellProtocol:class{vardata:LiveCellObjectProtocol!{getset}}这是我的课:classRepliesTableViewCell:UITableViewCell,LiveTableViewCellProtocol{vardata:RepliesCellObject!//ERROR!doesnotconformtoprotocol.}RepliesCellObject定义为:publicclassRepliesCellObject:NSObject,LiveCe

ios - 通用类类型不符合 Any

我在将泛型类存储在数组中时遇到问题。我应该如何在保持对原始类型的引用的同时为我的数组格式化类型(我知道我可以做varmyClasses:[Any]=[]但是当从我的数组中检索变量时这不会有帮助:(示例如下:importUIKitprotocolReusable{}extensionUITableViewCell:Reusable{}extensionUICollectionViewCell:Reusable{}classSomeClasswhereT:Reusable{init(){}}varmyClasses:[SomeClass]=[]myClasses.append(SomeCl

swift - 泛型类型 'T' 不符合协议(protocol) 'Encodable'

我正在尝试快速使用泛型来解释http响应。所有Json响应在顶部都有相同的签名:{"request":"foo","result":"[{},{}....]}所以我正在使用这个:publicstructHttpResponse{publicletrequest:Bool?publicletresult:DATA?enumCodingKeys:String,CodingKey{caserequest="request"caseresult="result"}..在我的网络层:finalclassNetwork{funcgetItems(_path:String)->Observable>