I want to be able to pass the data filelocation to my other view controller. I was able to pass it but it only displays one filelocation when displayed on the view controller. Where I am getting multiple from the son and all the cells refer back to that one last one. How can i fix this? Heres my code:
if let filelocation = fileList["urllocation"] as? String
{
TableData1.append(filelocation)
fileLocationLabelString = (filelocation)
}
override func prepareForSegue(segue: UIStoryboardSegue, sender: AnyObject?) {
selectedFileLocation = fileLocationLabelString
if(segue.identifier == "detailView") {
let vc = segue.destinationViewController as! DisplayWorkViewController
vc.selectedFileLocation = selectedFileLocation
vc.selectedLabel = selectedLabel
print("selectedFileLocation = \(vc.selectedFileLocation)")
}
}
TableData1 is the array variable and fileLocationLabelString is just a String. In order to get the complete list of locations, you have to pass TableData1 and not fileLocationLabelString
EDIT:
DisplayWorkViewController
var listLocation: Array<String> = [""]
current view Controller
if let filelocation = fileList["urllocation"] as? String
{
TableData1.append(filelocation)
fileLocationLabelString = (filelocation)
}
override func prepareForSegue(segue: UIStoryboardSegue, sender: AnyObject?) {
selectedFileLocation = fileLocationLabelString
if(segue.identifier == "detailView") {
let vc = segue.destinationViewController as! DisplayWorkViewController
vc.selectedFileLocation = selectedFileLocation
vc.selectedLabel = selectedLabel
vc.listLocation = TableData1
print(vc.listLocation.count)
print("selectedFileLocation = \(vc.selectedFileLocation)")
}
}
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.