如何将int转换为nsindexpath?

Ada*_*ung 19 nsuserdefaults nsindexpath ios swift

我正在做一个基本的测验应用程序.选择是以表格视图的形式.如果用户移动到上一个问题,我想向他显示他之前选择的选项.我已将选择存储在NSUserDefaults中.如何将此int值转换为NSIndexpath并在我的tableview中使用它?

zis*_*oft 60

请参阅NSINdexPath UIKit Additions

在你的情况下你可以使用(Swift):

let indexPath = NSIndexPath(forRow: 0, inSection: 0)
Run Code Online (Sandbox Code Playgroud)

Swift 3.0:

let indexPath = IndexPath(row: 0, section: 0)
Run Code Online (Sandbox Code Playgroud)