Meine Situation: Ich möchte Abschnitt in Daten aus einem Array bei Index X in einer Reihe auf Index X speichern 1.Swift TableViewCell Array
Mein Code ist:
override func numberOfSectionsInTableView(tableView: UITableView) -> Int {
return 1
}
override func tableView(tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
return setObjectToPass.count
}
override func tableView(tableView: UITableView, titleForHeaderInSection section: Int) -> String? {
return "Section \(section)"
}
override func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell {
var cellEmpty = tableView.dequeueReusableCellWithIdentifier("LabelCell")
var countCell = 0
while countCell < setObjectToPass.count {
let indexPaths = NSIndexPath(forRow: countCell, inSection: 0)
let cell = tableView.dequeueReusableCellWithIdentifier("LabelCell", forIndexPath: indexPaths)
cell.textLabel!.text = String(setObjectToPass[countCell])
print(cell)
countCell+=1
return cell
}
Mein Problem, dass nur der erste Index des Arrays SetObjectToPass wird in die Cell.text
while counter < fetchResult?.count {
let set = fetchResult![counter]
counter+=1;
setObject.append((set.reps?.integerValue)!)
}
Ich empfehle die grundlegende Implementierung eines 'UITableViewDataSource' forschen. Was Sie in der 'cellForRowAtIndexPath (_ :)' Methode machen, ist sehr seltsam. –
Okay danke, ich gebe es eine Chance, noch irgendwelche Vorschläge? –
Was sind die SetObjectToPass-Array-Werte? –