jjzjj

argument

全部标签

swift 泛型 : Cannot convert value of type to expected argument type

这是我的代码:protocolSomeProtocol{}classA:SomeProtocol{}funcf1(ofType:T.Type,listener:(T?)->Void){}funcf2(ofType:T.Type,listener:([T]?)->Void){}funcg(){letl1:(SomeProtocol?)->Void=...letl2:([SomeProtocol]?)->Void=...f1(ofType:A.self,listener:l1)//NOERRORf2(ofType:A.self,listener:l2)//COMPILEERROR:Cann

Android运行项目时提示:No signature of method: build_*.android() is applicable for argument types

报错意思:没有方法的签名:build_*.文件中  android()适用于参数类型我发生这种情况是因为:1AndroidStudio的版本较高(2021.3.1P1),2编译版本较高30,所以提示build.gradle的android插件有问题发现:1,高版本的application写法不同;2,android{   ......   } 中声明编译SDK版本的参数也不同。所以照上图中修正,就可以正常运行了。

ios - swift 错误 : Reference to generic type Dictionary requires arguments in <. ..>

错误ReferencetogenerictypeDictionaryrequiresargumentsin出现在函数的第一行。我试图让函数返回从api检索到的NSDictionary。有人知道这里会发生什么吗?classfuncgetCurrentWeather(longitude:Float,latitude:Float)->Dictionary?{letbaseURL=NSURL(string:"https://api.forecast.io/forecast/\(apikey)/")letforecastURL=NSURL(string:"\(longitude),\(latit

ios - swift 错误 : Reference to generic type Dictionary requires arguments in <. ..>

错误ReferencetogenerictypeDictionaryrequiresargumentsin出现在函数的第一行。我试图让函数返回从api检索到的NSDictionary。有人知道这里会发生什么吗?classfuncgetCurrentWeather(longitude:Float,latitude:Float)->Dictionary?{letbaseURL=NSURL(string:"https://api.forecast.io/forecast/\(apikey)/")letforecastURL=NSURL(string:"\(longitude),\(latit

ios - Swift 和 CoreData,关系问题 (NSSet) - [NSSet intersectsSet :]: set argument is not an NSSet

我一直在尝试使用CoreData和Swift在关系中添加对象。我很茫然,我不明白为什么我的代码不起作用。我正在尝试向“团队”添加“事件”。我找不到已接受的答案(应该有效)和我的代码(无效)之间的区别。Teams.swift:importFoundationimportCoreDataclassTeams:NSManagedObject{@NSManagedvarteamName:String@NSManagedvarmatches:NSSet}extensionTeams{funcaddEventToTeam(event:Event){//self.mutableSetValueFor

ios - Swift 和 CoreData,关系问题 (NSSet) - [NSSet intersectsSet :]: set argument is not an NSSet

我一直在尝试使用CoreData和Swift在关系中添加对象。我很茫然,我不明白为什么我的代码不起作用。我正在尝试向“团队”添加“事件”。我找不到已接受的答案(应该有效)和我的代码(无效)之间的区别。Teams.swift:importFoundationimportCoreDataclassTeams:NSManagedObject{@NSManagedvarteamName:String@NSManagedvarmatches:NSSet}extensionTeams{funcaddEventToTeam(event:Event){//self.mutableSetValueFor

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