iOS UI Testing tap on first index of the table

Use -elementBoundByIndex on your app's cells.

XCUIApplication *app = [[XCUIApplication alloc] init];
[[app.cells elementBoundByIndex: 0] tap];

Swift

If you're doing UI Testing, this will be helpful:

let cellCount = app.tables.cells.count
XCTAssertTrue(cellCount > 0)

let firstCell = app.tables.cells.element(boundBy: 0)
XCTAssertTrue(firstCell.exists)
firstCell.tap()

To answer your question though, you only need these 2 lines:

let firstCell = app.tables.cells.element(boundBy: 0)
firstCell.tap()