Reputation: 2294
I simply have a ViewController
that I would like to dismiss
. And this is my dismissAction
:
@objc private func dismissView(){
self.dismiss(animated: true, completion: nil)
UserDefaultsService.shared.updateDataSourceArrayWithWishlist(wishlist: self.wishList)
let dataSourceArray = UserDefaultsService.shared.getDataSourceArray()
// update datasource array in MainVC
self.dismissWishlistDelegate?.dismissWishlistVC(dataArray: dataSourceArray, dropDownArray: self.dropOptions, shouldDeleteWithAnimation: false, wishlistToDelete: self.wishList)
}
Proble:
The dismiss animation is very clunky
and not fluent at all. I found out that if I remove everything in the function but only call self.dismiss
it is working perfectly fine. What is the issue here? Any idea on how I can fix this?
Upvotes: 0
Views: 141
Reputation: 100533
You can try to light-weight load in main thread by
DispatchQueue.global().async {
UserDefaultsService.shared.updateDataSourceArrayWithWishlist(wishlist: self.wishList)
}
And instead of let dataSourceArray = UserDefaultsService.shared.getDataSourceArray()
use self.wishList
directly in the last line
Upvotes: 1