Start IndexPath from one

1

I need to start it from one to show the corresponding data of the BD

func tableView(tableView: UITableView, didSelectRowAtIndexPath indexPath: NSIndexPath) {

    vcName = values[indexPath.row]["idCategoria"] as! String
    print(vcName)
    //performSegueWithIdentifier("show", sender: self)
}

override func prepareForSegue(segue: UIStoryboardSegue, sender: AnyObject!) {

    if (segue.identifier == "show") {

        if let vc: ViewController = segue.destinationViewController as? ViewController {
            vc.idCategoria = vcName
        }

    }
}
    
asked by Brandon Josué Cerezo 05.08.2016 в 17:37
source

1 answer

0

It is not possible to start it from 1, since it should not be like that. Before applying the solution that I will give you, I would review the database, because like everything else in programming, it is ideal to start from scratch.

Still, you can do the following:

vcName = values[indexPath.row + 1]["idCategoria"] as! String

Remember, if you have 10 rows, with the method that I have passed, the range will no longer be 0-9 but will become 1-10 and the application may pete when accessing an index that does not exist.

    
answered by 05.08.2016 / 18:44
source