I have stored 2 entries in coredata given like so(in the image)...
Here in the first row, the fname
is qwe
and lastname
is try
. And in the 2nd row, the fname
is awed
and lastname
is sdcv
. Typically if I try to populate these names in a tableview, I'll get in the first cell the name qwe
and in the 2nd cell the name awed
. But I want in the first cell the name qwe
and in the 2nd cell the name try
, How can I achieve this...?
The code for what would happen in a normal scenario would be something like so..
In cellForRow
..
let cell2: BestWishesTableViewCell = tableView.dequeueReusableCell(withIdentifier: "bdayWishesCellIdentifier") as! BestWishesTableViewCell
let objCust = customerDetailsArrTwo[indexPath.row]
cell2.nameLabel.text = objCust.fname
The numberOfRows
would be customerDetailsArrTwo.count
Use this code if 1st Cell is Firstname and 2nd cell is Lastname, 3rd cell 2nd object FirstName and 4th cell is 2nd object LastName and so on.
if indexPath.row %2 == 0 {
cell2.nameLabel.text = objCust.fname
}
else {
cell2.nameLabel.text = objCust.lname
}
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.