嘿,伙计们,我试着把实参加到TableView中,结果遇到了一个错误,叫做参数缺少实参。我是iOS开发的新手,所以我的代码可能不是最好的。
我要做的是创建三个不同的部分,每个部分都有一个相同类型的训练数组。即,mixedSection将会有混合类型的训练。因此,我运行了一个例程对象数组,并检查这些对象的类型,然后将其附加到正确的部分。然后我将把这些部分放到一个数组中,这就是我遇到问题的地方。
var routines :[Routine] = routineData;
override func viewDidLoad() {
super.viewDidLoad()
var mixedSection = routineSectionData(sectionNameX: "Mixed", routineInSectionX: [Routine]());
var strengthSection = routineSectionData(sectionNameX: "Strength", routineInSectionX: [Routine]());
var hypertrophySection = routineSectionData(sectionNameX: "Hypertrophy", routineInSectionX: [Routine]());
for Routine in routineData {
if (Routine.typeOfRoutine == "Mixed") {
mixedSection.routineInSection.append(Routine);
}
else if (Routine.typeOfRoutine == "Strength") {
strengthSection.routineInSection.append(Routine);
}
else {
hypertrophySection.routineInSection.append(Routine);
}
}
let routineSectionDataInfo = [routineSectionData(mixedSection), routineSectionData(strengthSection), routineSectionData(hypertrophySection)];
}我在调用中得到一个缺少参数routineSectionX的实参。我想当我在init routineSectionX routineSectionData的时候,我只是用了这个名字。
发布于 2015-07-31 04:23:52
您收到的错误消息意味着您没有正确完成Initialization parameters.
如果我有一个类:
class Person {
let firstName: String
let lastName: String
init(firstName: String, lastName: String) {
self.firstName = name
self.lastName = lastName
}
}我这样称呼它:
let me = Person(firstName: "ez")我收到与您相同的错误消息。因为我不会传递第二个参数。所以正确的方法应该是:
let me = Person(firstName: "ez", lastName: "coding")因此,检查您的类在初始化时期望的参数,并满足它们,错误就会消失。
https://stackoverflow.com/questions/31731822
复制相似问题