icanzilb / SwiftSpinner

A beautiful activity indicator and modal alert written in Swift (originally developed for my app DoodleDoodle) Using blur effects, translucency, flat and bold design - all iOS 8 latest and greatest
MIT License
2.19k stars 268 forks source link

not responding when using inside NSManagedObjectContext.perform{} #126

Open turk-jk opened 6 years ago

turk-jk commented 6 years ago

my code looks like this

    let bgContext = NSManagedObjectContext(concurrencyType: .mainQueueConcurrencyType)

    func doCoreData(progress : @escaping (Double) -> ()) {
        bgContext.perform {
            for i in 1...10{
                let cent : Double = Double(i)/Double(10)
                // do some coredata work adding and updating
                progress(cent)
            }
        }
    }

    func orgnizeThings (){
        doCoreData { (cent) in
            DispatchQueue.main.async {
                let perCent = cent * 100
                SwiftSpinner.show(progress: cent, title: "loading \(perCent)")
            }
        }
    }

calling the orgnizeThings() function will get the core data work done but I would like to to show the user how far the function is done

in this setup the SwiftSpinner view is frozen

andreamazz commented 6 years ago

Hey @turk-jk Did you try to print the percentage? Check if it prints the intermediate values, and at which speed. Sometimes the percentage in this kind of stuff is iffy.