jjzjj

subscriptable

全部标签

swift - 在设备上模糊使用 'subscript'

我的应用程序已在我的模拟器上完成,但当我尝试在我的手机上使用时,我遇到了2个错误“下标”的使用不明确我正在阅读这篇文章,但无法修复它。HowtosolveAmbiguoususeof'subscript'inSwift2?问题就在这里letfavs=rescataRegistrosFav()print(favs)print("-----------------------------------------------")if(arrayCompleta[row][2]==""){cell.imagenMovil.image=nil}else{cell.imagenMovil.imag

swift - 错误 : Cannot subscript a value of type 'X' with . ..'

错误:无法使用类型为“(safe:Int)”的索引为类型为“[CustomClass]”的值下标classCustomClass{letvalue:Stringinit(value:String){self.value=value}}extensionCollection{subscript(safe:Int)->Element?{ifsafe>count-1{returnnil}returnself[safe]}}letsteps:[CustomClass]=[]ifletstep=steps[safe:4]{//errorhere}为什么会这样? 最佳答

ios - '子字符串(来自 : )' is deprecated: Please use String slicing subscript with a ' partial range from' operator. Swift 4 错误

这个问题在这里已经有了答案:HowcanIuseStringsubstringinSwift4?'substring(to:)'isdeprecated:PleaseuseStringslicingsubscriptwitha'partialrangefrom'operator(21个答案)关闭5年前。我正在将我现有的应用程序从Swift3转换为Swift4。它给出了错误:'substring(from:)'isdeprecated:PleaseuseStringslicingsubscriptwitha'partialrangefrom'operator.和'characters'i

ios - 使用 FBSDKApplicationDelegate 时对成员 'subscript' 的引用不明确

我已经更新了swift3,我发现了很多错误。这是其中之一:Ambiguousreferencetomember'subscript'对于下一行funcapplication(_app:UIApplication,openurl:URL,options:[UIApplicationOpenURLOptionsKey:Any])->Bool{FBSDKApplicationDelegate.sharedInstance().application(app,open:url,sourceApplication:options["UIApplicationOpenURLOptionsSourc

swift - 从常量 : Ambiguous reference to member 'subscript' 获取值时出错

我正在使用enum和tuple以及枚举大小写的值。我无法从[String:String]常量中获取值。我不知道如何修复它,它必须是一个陷阱,但我不知道在哪里,因为key肯定是字符串:enumDictTypes:String{casesettingscaseoptionscaselocations}enumFileTypes:String{casejsoncasepList}funcgetCodebookUrlComponent()->String{varFileSpecs:(dictType:DictTypes,fileType:FileTypes,redownload:Bool)=(

swift - 在 Swift 中获取错误 Ambiguous reference to member 'subscript'

字典需要扩展以获取文本键值(如果存在)。执行以下代码并成功编译:extensionDictionarywhereKey:ExpressibleByStringLiteral,Value:AnyObject{funcgetValueForKeyPath(keyValue:String)->String{return((self["item_qty"]as?Dictionary)??["":""])?["text"]??""}}但是当我对方法做一些小改动时,出现错误:"Ambiguousreferencetomember'subscript'"extensionDictionarywher

ios - "Type ' 任务。在 Swift 中键入 ' has no subscript members"错误

关闭。这个问题是notreproducibleorwascausedbytypos.它目前不接受答案。这个问题是由于错别字或无法再重现的问题引起的。虽然类似的问题可能是on-topic在这里,这个问题的解决方式不太可能帮助future的读者。关闭6年前。Improvethisquestion这段代码给我一个错误;类型'task.Type'没有下标成员这是我的代码:structtask{varname="Un-Named"vardesc="Un-Described"}classTaskManager:NSObject{vartasks=task[]()funcaddTask(name:S

ios - 使用 Array 而不是 NSArray 时出现错误 "ambiguous reference to member subscript"

当我尝试访问数组类型值然后出现错误时,我在可能包含数组类型值的字典中收到类似“对成员下标的模糊引用”的错误。请检查以下代码。varoccupations=["Malcolm":"Captain","Kaylee":"Mechanic","Layme":["Engineer","Docter"]]as[String:Any]occupations["Jayne"]="PublicRelations"vararrOfLayme=occupations["Layme"]as!Array//gettingerrorhere,IfIuseNSArrayinsteadofarrayallwillw

ios - 错误 : Cannot subscript a value of type 'inout [Agenda]' (aka 'inout Array<Agenda>' )

我正在制作一个应用程序,当您按下一个表示紧急的按钮时,会有一个标签显示“紧急”。就在我实现与按钮的用户交互之前,我有一个数组(如下所示),其中一些对象具有urgent=true,但有些对象具有urgent=false,所以我可以从我的代码开始。MainTableViewController.swift中的数组:varcontent:[Agenda]=[Agenda(subject:"Readthisarticle",deadline:"1-2days",urgent:false),Agenda(subject:"Respondtothisemail",deadline:"ASAP",u

ios - Rx swift : How to use shareReplay to lazily get subscription

所以我希望能够懒惰地订阅共享数据,而不会在没有人订阅时持续存在。然后如果有人再次订阅,将创建一个新的可观察对象。我会使用一个变量,但如果没有人订阅,我不希望它持续存在(因为如果我使用数组或大于int的东西,我不想将它们保留在内存中)。我当前的实现有效,除非重新订阅它仍然获得最后一个值,这意味着该值仍然存在。我正在考虑将observable设置为nil,但我不知道该在哪里做。谁能帮我完成这个?下面的代码显示它大部分工作正常,但看起来数据在没有人订阅的情况下仍然存在。varswitchTwoDisposable:Disposable?=nil​@IBActionfuncswitchOneC