gpt4 book ai didi

arrays - 迅速,将 NSIndexpath 转换为 Int

转载 作者:行者123 更新时间:2023-12-04 16:52:33 28 4
gpt4 key购买 nike

我有一个表格 View ,每个单元格中有一个按钮。当它被点击时,我有一个 didselectrow 功能。我想使用我的索引路径从给出单元格内容的数组中获取一个值。如何将此 NSIndexpath 转换为 int 以在数组中使用?

最佳答案

您最可能想要的是 属性(property)。你可以看到一个 example here .

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

let alert = UIAlertController(title: "Item selected", message: "You selected item \(indexPath.row)", preferredStyle: UIAlertControllerStyle.Alert)

alert.addAction(UIAlertAction(title: "OK",
style: UIAlertActionStyle.Default,
handler: {
(alert: UIAlertAction!) in println("An alert of type \(alert.style.hashValue) was tapped!")
}))

self.presentViewController(alert, animated: true, completion: nil)

}

关于arrays - 迅速,将 NSIndexpath 转换为 Int,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28027110/

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com