__am trying to print my values in table view but am getting double-double index.row value am returning devices.count in numberofrowsinsection function which is 22 but am getting ony 5 rows in cellforrowatindex function __
func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
return self.devices?.count ?? 0;
}
func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
print(devices?.count)
print("INDEXPATH :----- \(indexPath.row)")
let cell = tableView.dequeueReusableCell(withIdentifier: cellId, for: indexPath);
if let device = self.devices?[indexPath.row]{
cell.textLabel?.text = device.name;
// print("\(count) :- Device :- \(device) Index:------\(indexPath.row)")
count += 1
}
return cell;
}
func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) {
tableView.deselectRow(at: indexPath, animated: false);
if let block = self.deviceDidSelectBlock{
if let devices = self.devices, devices.count > 0 {
let device = devices[indexPath.row]
block(device);
}
}
self.dismiss(animated: false) {
}
}
func tableView(_ tableView: UITableView, heightForRowAt indexPath: IndexPath) -> CGFloat {
return 50;
}
func gestureRecognizer(_ gestureRecognizer: UIGestureRecognizer, shouldReceive touch: UITouch) -> Bool {
let loc = touch.location(in: self.view);
if loc.x < self.deviceTable.frame.maxX && loc.x > self.deviceTable.frame.minX && loc.y < self.deviceTable.frame.maxY && loc.y > self.deviceTable.frame.minY{
return false;
}else{
return true;
}
}