Swift PresentViewController termination block only works in debug mode not called in release

I have weird behavior with a termination block in Debug and Release. For instance:

        sourceViewController.presentViewController(ccVC, animated: true, completion: { () -> Void in
            NSUserDefaults.standardUserDefaults().setBool(true, forKey: kChromeCastInstructionsShown)
            NSUserDefaults.standardUserDefaults().synchronize()
            println("save bolean")
        })

In debugging: println ("save bolean") print string In relase: println ("save bolean") do not print anything

Any idea on this behavior? Is someone experimenting with a clear solution?

View Andrea

+4
source share
2 answers

It looks like a Swift compiler error (at least version 1.1), discussed here: https://github.com/ReactiveCocoa/ReactiveCocoa/issues/1632

In release builds, closing is sometimes not called, especially when they are sequenced as follows:

array.map({ $0 * 2 }).map({ $0 * 3 }).map({ $0 * 4 })...

Swift, Objective-C. Swift Compiler None [-Onone], .

Screen shot

:

func completionHandler() {
    NSUserDefaults.standardUserDefaults().setBool(true, forKey: kChromeCastInstructionsShown)
    NSUserDefaults.standardUserDefaults().synchronize()
    println("save bolean")
}

sourceViewController.presentViewController(ccVC, animated: true, completion: completionHandler)

, , .

+10

xcode 7.

  let delay = 0.2 * Double(NSEC_PER_SEC)
  let time = dispatch_time(DISPATCH_TIME_NOW, Int64(delay))

            dispatch_after(time, dispatch_get_main_queue(), {



            })

, None [-OO]

0

All Articles