草庐IT

ARGUMENT

全部标签

xcode - 快速关闭 : Cannot convert value of type '(_) -> Bool' to expected argument type

我在Swift中使用filter()方法,但遇到了一个我似乎无法在Playground上重现的问题。编辑:在此处上传示例项目:https://www.dropbox.com/s/5ce5uyxnpb0mndf/WeirdSwifty.zip?dl=0我有一个Card结构,其中包含一个CardType枚举:structCard{varname=""vartype:CardTypeenumCardType{caseRedcaseBlack}}还有一个Player类,它维护这些Card项目的数组:classPlayer{varhand:[Card]init(){hand=...}funcre

xcode - 快速关闭 : Cannot convert value of type '(_) -> Bool' to expected argument type

我在Swift中使用filter()方法,但遇到了一个我似乎无法在Playground上重现的问题。编辑:在此处上传示例项目:https://www.dropbox.com/s/5ce5uyxnpb0mndf/WeirdSwifty.zip?dl=0我有一个Card结构,其中包含一个CardType枚举:structCard{varname=""vartype:CardTypeenumCardType{caseRedcaseBlack}}还有一个Player类,它维护这些Card项目的数组:classPlayer{varhand:[Card]init(){hand=...}funcre

arrays - 尝试将数组 append 到 Swift 中的其他数组时获取 "extraneous argument label"

我在调用中得到了无关的参数标签'contentsOf:'array.append(contentsOf:test)尝试在playground中运行此代码时出错:importCocoavararray:[Any]=[]lettest=[""]array.append(contentsOf:[""])array.append(contentsOf:test)为什么会这样?据我了解,有两个带有空字符串的相等数组。 最佳答案 要在评论中回答您的具体问题,在这种情况下,您只需要强制转换,以便Swift知道您知道。在这种情况下,由于SKShap

arrays - 尝试将数组 append 到 Swift 中的其他数组时获取 "extraneous argument label"

我在调用中得到了无关的参数标签'contentsOf:'array.append(contentsOf:test)尝试在playground中运行此代码时出错:importCocoavararray:[Any]=[]lettest=[""]array.append(contentsOf:[""])array.append(contentsOf:test)为什么会这样?据我了解,有两个带有空字符串的相等数组。 最佳答案 要在评论中回答您的具体问题,在这种情况下,您只需要强制转换,以便Swift知道您知道。在这种情况下,由于SKShap

swift 4 : Cannot convert value of type '(_) -> ()' to expected argument type '() -> ()' or Argument passed to call that takes no arguments

使用XCode9,Beta3。Swift4。statsView.createButton("Buttonname"){[weakself]Voidin//stuffstuffself?.doSomething()}我遇到了数百个这样的错误,我该如何修复它们?错误:Cannotconvertvalueoftype'(_)->()'toexpectedargumenttype'()->()'Argumentpassedtocallthattakesnoarguments 最佳答案 我们似乎不再在Swift4中使用Voidin了。我是如何

swift 4 : Cannot convert value of type '(_) -> ()' to expected argument type '() -> ()' or Argument passed to call that takes no arguments

使用XCode9,Beta3。Swift4。statsView.createButton("Buttonname"){[weakself]Voidin//stuffstuffself?.doSomething()}我遇到了数百个这样的错误,我该如何修复它们?错误:Cannotconvertvalueoftype'(_)->()'toexpectedargumenttype'()->()'Argumentpassedtocallthattakesnoarguments 最佳答案 我们似乎不再在Swift4中使用Voidin了。我是如何

swift - Swift 3 : Cannot convert value of type 'NSMutableDictionary' to expected argument type '[AnyHashable : Any]!'

该代码在Swift3之前有效。(请问一下Swift3!)现在,它针对Flurry.logEvent(eventName,withParameters:userData!)行显示此错误:Cannotconvertvalueoftype'NSMutableDictionary'toexpectedargumenttype'[AnyHashable:Any]!'将userData!转换为[AnyHashable:Any]会产生以下错误:Cannotconvertvalueoftype'NSMutableDictionary'totype'[AnyHashable:Any]'incoercio

swift - Swift 3 : Cannot convert value of type 'NSMutableDictionary' to expected argument type '[AnyHashable : Any]!'

该代码在Swift3之前有效。(请问一下Swift3!)现在,它针对Flurry.logEvent(eventName,withParameters:userData!)行显示此错误:Cannotconvertvalueoftype'NSMutableDictionary'toexpectedargumenttype'[AnyHashable:Any]!'将userData!转换为[AnyHashable:Any]会产生以下错误:Cannotconvertvalueoftype'NSMutableDictionary'totype'[AnyHashable:Any]'incoercio

ios - Swift 编译器错误 : “Cannot invoke ' map' with an argument list of type '((_) -> _)' ”

我有一个要映射的范围,但出现错误“无法使用类型为‘((_)->_)’的参数列表调用‘map’”代码是这样的letpatterns=(0...5).map{verseNuminletverseNumberStartPattern="\"verse-num\">\(verseNum)(?:\\s?)?(.*?)\\s\(parsedVerse.chapterStart)\\s"ifverseNum==1{returnchapterStartPattern+"(.*?)如果我取出闭包中的所有内容并只返回“”,那么编译器不会报错。但是,即使我添加一行而不是返回空字符串,编译器也会报错,例如fo

ios - Swift 编译器错误 : “Cannot invoke ' map' with an argument list of type '((_) -> _)' ”

我有一个要映射的范围,但出现错误“无法使用类型为‘((_)->_)’的参数列表调用‘map’”代码是这样的letpatterns=(0...5).map{verseNuminletverseNumberStartPattern="\"verse-num\">\(verseNum)(?:\\s?)?(.*?)\\s\(parsedVerse.chapterStart)\\s"ifverseNum==1{returnchapterStartPattern+"(.*?)如果我取出闭包中的所有内容并只返回“”,那么编译器不会报错。但是,即使我添加一行而不是返回空字符串,编译器也会报错,例如fo