3 Replies
      Latest reply on Oct 31, 2019 12:58 AM by Claude31
      sunilfromcupertino Level 1 Level 1 (0 points)

        let dispatchGroup = DispatchGroup()

                for _ in 1...views.count { dispatchGroup.enter() }

                DispatchQueue.main.asyncAfter(deadline: .now() + delay) {

                    for (index, view) in views.enumerated() {

                        view.alpha = initialAlpha

                        view.animate(animations: animations,

                                     reversed: reversed,

                                     initialAlpha: initialAlpha,

                                     finalAlpha: finalAlpha,

                                     delay: Double(index) * animationInterval,

                                     duration: duration,

                                     usingSpringWithDamping: dampingRatio,

                                     initialSpringVelocity: velocity,

                                     options: options,

                                     completion: { dispatchGroup.leave() })

                    }

                }

              

                dispatchGroup.notify(queue: .main) {

                    completion?()

                }

        • Re: Dispatch group not working properly in iOS 13
          Claude31 Level 8 Level 8 (7,005 points)

          Could you explain what "not working properly in iOS 13" mean ?

           

          • What do you expect ?
          • What do you get ?

           

          Environment ?

          • Version of XCode
          • Simulator or device ?

          Please provide more information on your code

          • delay value ?
          • how are animations defined, as well as all the other parameters
            • Re: Dispatch group not working properly in iOS 13
              sunilfromcupertino Level 1 Level 1 (0 points)

              In iOS 13 completioner handler didn't call and gives crash. Nothing printed on console.
              Xcode 11.1, Simulator iPhone 11 Pro

                • Re: Dispatch group not working properly in iOS 13
                  Claude31 Level 8 Level 8 (7,005 points)

                  I formatted to more easily reference

                   

                  let dispatchGroup = DispatchGroup()
                          for _ in 1...views.count { dispatchGroup.enter() }
                          DispatchQueue.main.asyncAfter(deadline: .now() + delay) {
                              for (index, view) in views.enumerated() {
                                  view.alpha = initialAlpha
                                  view.animate(animations: animations,
                                               reversed: reversed,
                                               initialAlpha: initialAlpha,
                                               finalAlpha: finalAlpha,
                                               delay: Double(index) * animationInterval,
                                               duration: duration,
                                               usingSpringWithDamping: dampingRatio,
                                               initialSpringVelocity: velocity,
                                               options: options,
                                               completion: { dispatchGroup.leave() })
                              }
                          }
                        
                          dispatchGroup.notify(queue: .main) {
                              completion?()
                          }

                   

                  Which completion does not get called ? Line 20 ?

                  If so, where is this completion defined ?