     }
     
     public func collectionView(_ collectionView: UICollectionView, didSelectItemAt indexPath: IndexPath) {
-        doneButtonItem.isEnabled = Int(collectionView.indexPathsForSelectedItems?.count) > 0
         let asset = AssetsManager.shared.photoArray[indexPath.row]
         select(asset: asset, at: indexPath)
+        doneButtonItem.isEnabled = selectedArray.count > 0
         delegate?.assetsPicker(controller: picker, didSelect: asset, at: indexPath)
     }
     

    public func assetsAlbumViewController(controller: AssetsAlbumViewController, selected album: PHAssetCollection) {
        AssetsManager.shared.selectedAlbum = album
        title = album.localizedTitle
        collectionView.reloadData()
    }
}


    }
    
    public func collectionView(_ collectionView: UICollectionView, didDeselectItemAt indexPath: IndexPath) {
        let asset = AssetsManager.shared.photoArray[indexPath.row]
        deselect(asset: asset, at: indexPath)
        doneButtonItem.isEnabled = selectedArray.count > 0
        delegate?.assetsPicker(controller: picker, didDeselect: asset, at: indexPath)
    }
}
