[英]how can I retrieve data from firebase to a table view controller and pass it to another view controller
I retrieved my data using firebase database into a table view cell in a view controller. 我使用firebase数据库将数据检索到视图控制器中的表视图单元中。 I want to forward the data to another view controller.
我想将数据转发到另一个视图控制器。 enter image description here i try by creating variables assigning them to table view cells label but when trying to retrieve the app crashed enter image description here .
我尝试在此处输入图片描述,方法是创建将变量分配给表格视图单元格标签的变量,但是当尝试检索崩溃的应用程序时,请在此处输入图片描述 。 here are my sample codes enter image description here
这是我的示例代码, 在此处输入图片描述
This function expects an Any
as parameter, so in your function didSelectRowAt
you can get the object using the index atIndexPath
getting the object from the array you used to populate the tableView
and send this object in the sender
parameter: 该函数需要一个
Any
作为参数,因此在函数didSelectRowAt
您可以使用索引atIndexPath
获取该对象,该索引从用于填充tableView
的数组中获取该对象,并在sender
参数中发送该对象:
performSegue(withIdentifier: String, sender: Any?)
You should then implement this function: 然后,您应该实现此功能:
override func prepareForSegue(segue: UIStoryboardSegue, sender: AnyObject?)
There you can retrieve your object in the sender
and the view controller in the property segue.destination
which is a UIViewController
so you can convert it to your ViewController and pass the object to the next one. 在那里,您可以在
sender
segue.destination
检索对象,并在属性segue.destination
检索视图控制器,该属性是一个UIViewController
因此您可以将其转换为ViewController并将该对象传递给下一个对象。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.