草庐IT

ambiguity

全部标签

ios - swift 3.0 : Ambiguous reference to member 'Subscript' issue in push notification

这是下面的代码,但我在swift3中收到以下错误funcapplication(_application:UIApplication,didReceiveRemoteNotificationuserInfo:[AnyHashable:Any],fetchCompletionHandlercompletionHandler:@escaping(UIBackgroundFetchResult)->Void){notificationReceived(notification:userInfoas[NSObject:AnyObject])}funcnotificationReceived(n

ios - Xcode 7.3 : "Ambiguous expansion of macro" when re-defining macro in prefix file

我正在使用Xcode7.3,并且收到“宏扩展不明确”的警告,这是针对在Foundation中定义的宏,但我在前缀文件中未定义和重新定义的宏。我启用了模块。重现:在build设置中将“启用模块(C和Objective-C)”设置为"is"使用以下前缀文件:#import#undefassert#defineassert(e)NSLog(@"hi")//implementationisnotimportant使用下面的主要源文件:intmain(){assert(42);return0;}然后在Xcode中构建。它在源文件中使用“断言”宏的行上显示“宏‘断言’的扩展不明确”警告。“Expa

ios - "Ambiguous use of subscript"新 Swift 更新后出错

我的项目之前运行良好,如果使用模拟器仍然运行良好。但是,当我连接iPhone并尝试运行该项目时,出现此错误:“下标使用不明确”在此行检索JSON信息时:letchannels=jsonResult["channels"]?[0]as?[String:AnyObject]感谢任何解决此问题的帮助! 最佳答案 编译器似乎更受类型限制。jsonResult["channels"]的结果类型是AnyObject您必须通过检查数组的值来帮助编译器。ifletchannels=jsonResult["channels"]as?[AnyObjec

ios - Xcode 10、Swift 4.2 中的 "Ambiguous use"

我正在使用图书馆DropDown这是用Swift编写的iOS的MaterialDesign下拉菜单。我正在设置View的cornerRadius,如下所示,因为DropDown是UIView的子类。letdropDown=DropDown()dropDown.cornerRadius=10它在Xcode9.4中运行良好,但在升级到Xcode10后出现以下错误:AmbiguoususeofcornerRadius可能是什么问题? 最佳答案 根据您的描述,您正在尝试为UIView设置不直接应用于View的角半径。您可以像这样为UIVie

swift - 被 Swift 中的 Ambiguous Reference Member Reference 错误搞糊涂了

鉴于此工作区示例:importFoundationimportCoreBluetoothclassSomething:NSObject,CBPeripheralDelegate{varperipheral:CBPeripheral!funcperipheral(peripheral:CBPeripheral,didUpdateValueForDescriptordescriptor:CBDescriptor,error:NSError?){}funcfoobar(){self.peripheral.writeValue([],forDescriptor:0)//Iusearealval

ios - Swift 3 中的 "Ambiguous Reference To"错误

下午好,我正在尝试编写一个音乐播放应用程序,我正在尝试在其中实现一些名为“STK音频播放器”的开源代码,该代码是用ObjectiveC编写的。尝试从导入的源调用方法时,我收到以下编译错误。“对成员游戏的模糊引用”importUIKitclassViewController:UIViewController{varaudioPlayer=STKAudioPlayer()overridefuncviewDidLoad(){super.viewDidLoad()//Doanyadditionalsetupafterloadingtheview,typicallyfromanib.letson

arrays - 运行 XCTests 时出现 "Ambiguous use of ' MYFUNCTION( )'"错误

我在尝试运行XCTests时遇到几个函数的错误。例如,我有一个简单的数组扩展来提取一个唯一的数组:publicextensionCollectionTypewhereGenerator.Element:Hashable{///Returnsthecollectionwithduplicatevaluesin`self`removed.varunique:[Generator.Element]{get{varseen:[Generator.Element:Bool]=[:]returnself.filter{(element)->Boolinreturnseen.updateValue(

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 - 使用 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