Computer >> Hướng Dẫn Máy Tính >  >> Lập Trình >> iOS

Tạo NSIndexPath cho TableView trong iOS

Index path là cặp giá trị biểu diễn hàng (row) và phần (section) của table view. Có thể tạo bằng Objective-C hoặc Swift.

Objective-C:

NSIndexPath *myIP = [NSIndexPath indexPathForRow:5 inSection:2];

Swift:

IndexPath(row: 2, section: 4)

Thường dùng trong cellForRowAt:

let cell = tblView.cellForRow(at: IndexPath(row: 5, section: 2))