Reputation: 14058
The following code produces a runtime error and I can't figure out how. Any thoughts?
var foo: IndexPath
foo = IndexPath()
foo.row = 1
var i = 0
Upvotes: 1
Views: 477
Reputation: 14397
There is a preCondition in swift to access row of indexpath
/// The section of this index path, when used with `UITableView`.
///
/// - precondition: The index path must have exactly two elements.
public var section: Int
/// The row of this index path, when used with `UITableView`.
///
/// - precondition: The index path must have exactly two elements.
public var row: Int
If you want to access or change row you need to initialise indexPath with row and section
var foo: IndexPath
foo = IndexPath(row: 0, section: 0)
foo.row = 1 // return foo (1,0)
Upvotes: 1