{"action":"closed","issue":{"url":"https://api.github.com/repos/mxcl/PromiseKit/issues/416","repository_url":"https://api.github.com/repos/mxcl/PromiseKit","labels_url":"https://api.github.com/repos/mxcl/PromiseKit/issues/416/labels{/name}","comments_url":"https://api.github.com/repos/mxcl/PromiseKit/issues/416/comments","events_url":"https://api.github.com/repos/mxcl/PromiseKit/issues/416/events","html_url":"https://github.com/mxcl/PromiseKit/issues/416","id":153005378,"number":416,"title":"Delegate-system wrappers seem to return immediately when not used at the beginning of the chain","user":{"login":"MatteoManni","id":8668385,"avatar_url":"https://avatars.githubusercontent.com/u/8668385?v=3","gravatar_id":"","url":"https://api.github.com/users/MatteoManni","html_url":"https://github.com/MatteoManni","followers_url":"https://api.github.com/users/MatteoManni/followers","following_url":"https://api.github.com/users/MatteoManni/following{/other_user}","gists_url":"https://api.github.com/users/MatteoManni/gists{/gist_id}","starred_url":"https://api.github.com/users/MatteoManni/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/MatteoManni/subscriptions","organizations_url":"https://api.github.com/users/MatteoManni/orgs","repos_url":"https://api.github.com/users/MatteoManni/repos","events_url":"https://api.github.com/users/MatteoManni/events{/privacy}","received_events_url":"https://api.github.com/users/MatteoManni/received_events","type":"User","site_admin":false},"labels":[],"state":"closed","locked":false,"assignee":null,"milestone":null,"comments":0,"created_at":"2016-05-04T12:59:20Z","updated_at":"2016-05-04T13:06:01Z","closed_at":"2016-05-04T13:06:01Z","body":"I have been trying for a couple of days to figure out a solution for an unexpected behaviour of promise-wrapped delegate systems (UIAlertView+PromiseKit, PMKLocationManager etc..).\r\n\r\nIn my fairly typical scenario of an app's Setup process, I am trying to chain up a series of operations that the user has to go through when the app loads. For the sake of this example, let's restrict the case to only two steps: logging the user into a Restful system followed by presenting an alertView and waiting for user's interaction.\r\n\r\nBelow is my code, where:\r\n\r\n- LoginToService is a promise-able version of a block-based method obtained via extending MCUser with PromiseKit. This works as expected and returns once the user had logged in, or fails with an error.\r\nIn the 'then' clause of the successful login, I present an alertView by returning its promised version via alert.promise().\r\n\r\n- I would expect that promise to be fulfilled before the successive .then clause (and in the end the 'finally' clause) gets called - the alert's promise should be fulfilled when the the user clicks on button to dismiss it, as per implementation of PromiseKit's delegate system wrappers: this works just fine the observed behaviour when I use alert.promise().then to start the chain of Promises -\r\n\r\n`    // Doesn't work: alert.promise returns immediately \r\nlet user = MCUser.sharedInstance()\r\nuser.logInToService(.RestServiceOne, delegate: self).then { _ -> AnyPromise in\r\n    MCLogInfo(\"LogInToService: Promise fulfilled\")\r\n    let alert = UIAlertView(title: \"Title\", message: \"Msg\", delegate: nil, cancelButtonTitle: \"Cancel\", otherButtonTitles: \"Hello\")\r\n    return alert.promise()\r\n    }.then { (obj:AnyObject) -> Void in\r\n        print(\"Clicked\")\r\n    }.finally {\r\n        print(\"Finally\")\r\n    }.catch_ { error in\r\n print(\"Error\")\r\n}`\r\n\r\nWhat I observe is that the chain continues immediately without waiting for the user to click, with the 'Clicked' and 'Finally' messages being printed to console and the alert on screen waiting for an action. Am I obviously missing something or are those delegate-system wrappers not meant to be used if not at the beginning of the Promise chain?"}}