-1

I have a NSView controller called LOGIN

I have a NSTabViewController called LISTS and this has two tabs: playlistLists - associated with the class PlaylistLists, albums - associated with the class Albums

I need to pass a variable from login to playlistLists and i think something like this should work (its from another post), but this is for ios and I need it for macOS

override func prepare(for segue: UIStoryboardSegue, sender: Any?) {
    let barViewControllers = segue.destination as! UITabBarController
    let destinationViewController = barViewControllers.viewControllers?[0] as! FirstViewController
    destinationViewController.test = "Hello TabBar 1"

    // access the second tab bar
    let secondDes = barViewControllers.viewControllers?[1] as! SecondViewController
    secondDes.test = "Hello TabBar 2" }

so I change it to this:

override func prepare(for segue: NSStoryboardSegue, sender: Any?) {
    let barViewControllers = segue.destinationControlles as! NSTabViewController
    let destinationViewController = barViewControllers.viewControllers?[0] as! playlistLists
    destinationViewController.test = "Hello TabBar 1"

    // access the second tab bar
    let secondDes = barViewControllers.viewControllers?[1] as! SecondViewController
    secondDes.test = "Hello TabBar 2"  }

This line I can't figure out how to change it for macOS:

    let destinationViewController = barViewControllers.viewControllers?[0] as! playlistListsts

or maybe is not the right way to do it.

Thanks for your help

1 Answers1

0

When you use as! to cast from one type to another, you have to specify a class (or struct) type, not a variable or property name. So if playlistsLists is a property of type PlaylistLists, then your line needs to be

let destinationViewController = barViewControllers.viewControllers?[0] as! PlaylistList
NRitH
  • 13,441
  • 4
  • 41
  • 44
  • well the problem is that I cant seem to use that line beacuse it says: Value of tyoe NSTabViewController has no member viewControllers, so I think that line should be adapted, PlaylistLists is actually my class – Manuel Gonzalez Feb 11 '19 at 20:25