0

i tried a much, but it doesn't work :-(

I have written a class with a part is this:

            if useKeychain {

                let server : String = "smb://cloud.amrhein.info"
                let user : String = "gerald"
                let pwd : String = "password"

                let keychain = Keychain(server: server, protocolType: .SMB)


                if let output : String = try! keychain.get(user) {

                    print("Password (if): \(output)")


                } else {

                    print("start Ask4pwd")

                    var pWindowController : NSWindowController?

                    if let storyboard : NSStoryboard = NSStoryboard(name: "Main",bundle: nil) as NSStoryboard
                    {
                        if let vc = storyboard.instantiateControllerWithIdentifier("passwordViewController") as? passwordViewController
                        {
                            let myWindow = NSWindow(contentViewController: vc)
                            myWindow.makeKeyAndOrderFront(self)
                            pWindowController = NSWindowController(window: myWindow)

                            pWindowController!.showWindow(self)

                        }
                    }

                    do {

                        try keychain
                            .accessibility(.Always)
                            .label("\(server) (\(user))")
                            .comment("Use for Mount Volumes")
                            .set(pwd, key: user)
                    } catch let error {
                        print(error)
                    }
                }
            } else {
                password = passwordsArray[index!]
            }

            if password == "" {
                print("No password set - break!")
                break
            }

....

i have settled my environment that no password is found. i see the "start Ask4pwd" print in console!

the class itself is running, but the window for asking the password do not open when no password is fount in keychain!

in the Mainstoryboard i have created a new view controller "passwordViewController" and gave it also the Storyboard ID: passwordViewController

This view controller has no sequel to the Main Window controller!

I do not want that the gui comes up when app starts, i have disabled "is initial controller" on Mainwindowcontroller

i gogoled and viewed youtube videos a lot - i do not reach my goal...

Who can help me?

user3105274
  • 11
  • 1
  • 3
  • i found the solution and want to post for the other guys here :-) here i found the main Info how to solve: [link(]http://stackoverflow.com/questions/27955789/executing-code-in-a-different-window-view-controller-from-the-current-window-vie) // AppDelegate.swift import Cocoa var myWindowController : NSWindowController? var passwordViewController : NSViewController? let storyboard = NSStoryboard(name: "Main", bundle: nil) – user3105274 Jan 21 '16 at 09:30
  • func openAsk4Pwd () myWindowController = storyboard.instantiateControllerWithIdentifier("mainWindowController") as? NSWindowController passwordViewController = storyboard.instantiateControllerWithIdentifier("pwdView") as? NSViewController myWindowController?.window?.contentViewController = passwordViewController myWindowController?.showWindow(self) } – user3105274 Jan 21 '16 at 09:37

0 Answers0