pretty basic question here but it has me stuffed...
这是一个很基本的问题,但它让我很困惑……
I'm trying to call a function (defined in another class) using this method:
我正在尝试使用这个方法调用一个函数(在另一个类中定义):
var idarray = Profile.getIDArray(Globals.friendlist);
where Globals.friendlist is an array of Profiles (i.e. [Profile?] )
Globals.friendlist是一个配置文件数组(例如[Profile?])
Now here is my function for .getIDArray
这是。getidarray的函数
func getIDArray(inputarray:[Profile?]) -> [String] {
//Blah - code that returns an array of Strings
}
Whenever I try to compile this I keep getting the following error:
每当我试图编译它时,我总是得到以下错误:
Cannot invoke 'getIDArray' with an argument list of type '([Profile?])'
Now here is where I'm confused - because I'm pretty certain that my function is accepting [Profile?] as the parameter type!
这里我有点困惑,因为我很确定我的函数接受[Profile?]作为参数类型!
What's going wrong - is there something introduced in swift that I am unaware of?
出了什么问题——斯威夫特有什么我不知道的东西吗?
1 个解决方案
#1
4
You are invoking getIDArray as a type method. Probably you are missing a class
or static
keyword in the func declaration:
您调用getIDArray作为类型方法。可能您在func声明中缺少一个类或静态关键字:
class func getIDArray(... // if Profile is a class
static func getIDArray(... // if Profile is struct or enum
#1
4
You are invoking getIDArray as a type method. Probably you are missing a class
or static
keyword in the func declaration:
您调用getIDArray作为类型方法。可能您在func声明中缺少一个类或静态关键字:
class func getIDArray(... // if Profile is a class
static func getIDArray(... // if Profile is struct or enum