0

I have a task to call functions with a certain order synchronously with respect to each other.

I realized my function, but for some reason when I checked it, I found an anomaly. Let's say if you make a list of calls to resolve which rights and when you stop to resolve the first request for about 1 minute, the other permissions will slip through

class RunFuncs {
    typealias TypeFuncCall<T> = ((_ completed: @escaping (T) -> Void) -> Void)
    static func cascad<T>(dispatchQueue queue: DispatchQueue,
                          callFuncs funcs: [TypeFuncCall<T>], 
                          indexFuncRun index: Int = 0,
                          completedAll: @escaping (([T]) -> Void)) {
        queue.async {
            guard (funcs.count > index) else {
                completedAll([T]())
                return
            }
            let callOne = funcs[index]
            let indexNext = (index + 1)
            callOne() { [completedAll, funcs, indexNext] (resultOne) in
                RunFuncs.cascad(dispatchQueue: queue,
                                callFuncs: funcs,
                                indexFuncRun: indexNext,
                                completedAll: { (resultOther) in
                    var resultAll = resultOther
                    resultAll.insert(resultOne, at: 0)
                    completedAll(resultAll)
                })
            }
        }
    }
}
  • What does "the other permissions will slip through" mean here? – Rob Napier Sep 28 '18 at 13:10
  • @RobNapier, the call of other functions will be performed on the request for permission of any parameters, but there will be no query on the screen and the function will return a negative query result immediately. – Oleg Privalov Oct 01 '18 at 03:38

0 Answers0