Physical Address
304 North Cardinal St.
Dorchester Center, MA 02124
Physical Address
304 North Cardinal St.
Dorchester Center, MA 02124
[ad_1]
I am attempting to implement drop and drag, however getting an error: try and insert row 4 into part 1, however there are solely 4 rows in part 1 after the replace
I get this error, when attempt to drop merchandise from Reminder to my tableView
.
I’ve this code im my ViewController:
extension ProfileViewController: UITableViewDropDelegate {
func tableView(_ tableView: UITableView, performDropWith coordinator: UITableViewDropCoordinator) {
let destinationIndexPath = IndexPath(row: tableView.numberOfRows(inSection: 1), part: 1)
let merchandise = coordinator.gadgets[0]
swap coordinator.proposal.operation {
case .copy:
print("Copying...")
let itemProvider = merchandise.dragItem.itemProvider
itemProvider.loadObject(ofClass: NSString.self) { string, error in
if (string as? String) != nil {
let fasting = Fasting(autor: "Writer", description: "Description", picture: UIImage(named: "регби") ?? UIImage(), numberOfLikes: 0, numberOfviews: 0)
self.addGeocache(fasting, at: destinationIndexPath.row)
DispatchQueue.fundamental.async {
tableView.insertRows(at: [destinationIndexPath], with: .computerized)
}
}
}
default:
return
}
}
Right here I create numberOfRows
im my tableView
:
func tableView(_ tableView: UITableView, numberOfRowsInSection part: Int) -> Int {
if part == 0 {
return 1
} else {
return Circulate.sections.fasting.rely
}
}
That is my array of parts in part 1:
struct Circulate {
static let sections = FastingSections(
fasting: [
Fasting(autor: "Gustav",
description: "Today i did eat this",
image: UIImage(named: "эко-мороженое 1")!,
numberOfLikes: 100,
numberOfviews: 100),
Fasting(autor: "Dasha",
description: "I love this watch",
image: UIImage(named: "часы")!,
numberOfLikes: 200,
numberOfviews: 200),
Fasting(autor: "Misha",
description: "Playing rugby with my friends",
image: UIImage(named: "регби")!,
numberOfLikes: 300,
numberOfviews: 300),
Fasting(autor: "Nikita",
description: "Soon...",
image: UIImage(named: "cosmos")!,
numberOfLikes: 400,
numberOfviews: 400),
]
)
}
[ad_2]