diff --git a/Kiwix-iOS/Controller/Library/LocalBooksController.swift b/Kiwix-iOS/Controller/Library/LocalBooksController.swift index f2791fe0..27f107d0 100644 --- a/Kiwix-iOS/Controller/Library/LocalBooksController.swift +++ b/Kiwix-iOS/Controller/Library/LocalBooksController.swift @@ -132,7 +132,7 @@ class LocalBooksController: UIViewController, UITableViewDelegate, UITableViewDa let delete = UITableViewRowAction(style: .Destructive, title: LocalizedStrings.delete) { (action, indexPath) -> Void in guard let book = self.fetchedResultController.objectAtIndexPath(indexPath) as? Book else {return} self.managedObjectContext.performBlock({ () -> Void in - if let zimURL = ZimMultiReader.sharedInstance.readers[book.id]?.fileURL { + if let zimURL = ZimMultiReader.shared.readers[book.id]?.fileURL { FileManager.removeItem(atURL: zimURL) let indexFolderURL = zimURL.URLByAppendingPathExtension("idx") diff --git a/Kiwix-iOS/Controller/Main/MainController.swift b/Kiwix-iOS/Controller/Main/MainController.swift index dff51102..4a96a3f6 100644 --- a/Kiwix-iOS/Controller/Main/MainController.swift +++ b/Kiwix-iOS/Controller/Main/MainController.swift @@ -54,7 +54,7 @@ class MainController: UIViewController { navigationItem.titleView = searchBar searchBar.delegate = self - ZimMultiReader.sharedInstance.delegate = self + ZimMultiReader.shared.delegate = self NSUserDefaults.standardUserDefaults().addObserver(self, forKeyPath: "webViewNotInjectJavascriptToAdjustPageLayout", options: .New, context: context) NSUserDefaults.standardUserDefaults().addObserver(self, forKeyPath: "webViewZoomScale", options: .New, context: context) @@ -110,7 +110,7 @@ class MainController: UIViewController { let urlString = activity.userInfo?["ArticleURL"] as? String, let url = NSURL(string: urlString), let host = url.host else {return} - if ZimMultiReader.sharedInstance.readers.keys.contains(host) { + if ZimMultiReader.shared.readers.keys.contains(host) { load(url) } else { // TODO: - Alert cannot complete hand off @@ -132,7 +132,7 @@ class MainController: UIViewController { } func loadMainPage(id: ZimID) { - guard let reader = ZimMultiReader.sharedInstance.readers[id] else {return} + guard let reader = ZimMultiReader.shared.readers[id] else {return} let mainPageURLString = reader.mainPageURL() let mainPageURL = NSURL.kiwixURLWithZimFileid(id, contentURLString: mainPageURLString) load(mainPageURL) diff --git a/Kiwix-iOS/Controller/Main/MainControllerDelegates.swift b/Kiwix-iOS/Controller/Main/MainControllerDelegates.swift index b4035044..ffe50ee9 100644 --- a/Kiwix-iOS/Controller/Main/MainControllerDelegates.swift +++ b/Kiwix-iOS/Controller/Main/MainControllerDelegates.swift @@ -101,7 +101,7 @@ extension MainController: UIWebViewDelegate, SFSafariViewControllerDelegate, // MARK: - ZimMultiReaderDelegate func firstBookAdded() { - guard let id = ZimMultiReader.sharedInstance.readers.keys.first else {return} + guard let id = ZimMultiReader.shared.readers.keys.first else {return} loadMainPage(id) } diff --git a/Kiwix-iOS/Info.plist b/Kiwix-iOS/Info.plist index 795878aa..30ada7b1 100644 --- a/Kiwix-iOS/Info.plist +++ b/Kiwix-iOS/Info.plist @@ -49,7 +49,7 @@ CFBundleVersion - 1.8.277 + 1.8.279 ITSAppUsesNonExemptEncryption LSRequiresIPhoneOS diff --git a/Kiwix-iOSWidgets/Bookmarks/Info.plist b/Kiwix-iOSWidgets/Bookmarks/Info.plist index a049057f..269099c1 100644 --- a/Kiwix-iOSWidgets/Bookmarks/Info.plist +++ b/Kiwix-iOSWidgets/Bookmarks/Info.plist @@ -21,7 +21,7 @@ CFBundleSignature ???? CFBundleVersion - 1.8.280 + 1.8.282 NSExtension NSExtensionMainStoryboard diff --git a/Kiwix/Operations/ScanLocalBookOperation.swift b/Kiwix/Operations/ScanLocalBookOperation.swift index 10efd3f5..86161276 100644 --- a/Kiwix/Operations/ScanLocalBookOperation.swift +++ b/Kiwix/Operations/ScanLocalBookOperation.swift @@ -57,13 +57,13 @@ class ScanLocalBookOperation: Operation { let removedZimFileURLs = lastZimFileURLSnapshot.subtract(currentZimFileURLSnapshot) guard addedZimFileURLs.count > 0 || removedZimFileURLs.count > 0 else {return} - ZimMultiReader.sharedInstance.removeReaders(removedZimFileURLs) - ZimMultiReader.sharedInstance.addReaders(addedZimFileURLs) + ZimMultiReader.shared.removeReaders(removedZimFileURLs) + ZimMultiReader.shared.addReaders(addedZimFileURLs) } private func updateCoreData() { let localBooks = Book.fetchLocal(context) - let zimReaderIDs = Set(ZimMultiReader.sharedInstance.readers.keys) + let zimReaderIDs = Set(ZimMultiReader.shared.readers.keys) let addedZimFileIDs = zimReaderIDs.subtract(Set(localBooks.keys)) let removedZimFileIDs = Set(localBooks.keys).subtract(zimReaderIDs) @@ -77,7 +77,7 @@ class ScanLocalBookOperation: Operation { } for id in addedZimFileIDs { - guard let reader = ZimMultiReader.sharedInstance.readers[id] else {return} + guard let reader = ZimMultiReader.shared.readers[id] else {return} let book: Book? = { let book = Book.fetch(id, context: NSManagedObjectContext.mainQueueContext) return book ?? Book.add(reader.metaData, context: NSManagedObjectContext.mainQueueContext) @@ -89,7 +89,7 @@ class ScanLocalBookOperation: Operation { for (id, book) in localBooks { guard !context.deletedObjects.contains(book) else {continue} - guard let reader = ZimMultiReader.sharedInstance.readers[id] else {return} + guard let reader = ZimMultiReader.shared.readers[id] else {return} book.hasIndex = reader.hasIndex() } diff --git a/Kiwix/Operations/SearchOperation-old.swift b/Kiwix/Operations/SearchOperation-old.swift index cb12e6db..a02e625c 100644 --- a/Kiwix/Operations/SearchOperation-old.swift +++ b/Kiwix/Operations/SearchOperation-old.swift @@ -22,7 +22,7 @@ class SearchOperation: GroupOperation { self.results = results } - for (id, zimReader) in ZimMultiReader.sharedInstance.readers { + for (id, zimReader) in ZimMultiReader.shared.readers { let managedObjectContext = UIApplication.appDelegate.managedObjectContext guard let book = Book.fetch(id, context: managedObjectContext) else {continue} guard book.includeInSearch else {continue} diff --git a/Kiwix/URLProtocol/KiwixURLProtocol.swift b/Kiwix/URLProtocol/KiwixURLProtocol.swift index b331e91e..f60f4dcf 100644 --- a/Kiwix/URLProtocol/KiwixURLProtocol.swift +++ b/Kiwix/URLProtocol/KiwixURLProtocol.swift @@ -27,7 +27,7 @@ class KiwixURLProtocol: NSURLProtocol { client?.URLProtocol(self, didFailWithError: error) return } - guard let dataDic = ZimMultiReader.sharedInstance.data(id, contentURLString: contentURLString), + guard let dataDic = ZimMultiReader.shared.data(id, contentURLString: contentURLString), let data = dataDic["data"] as? NSData, let mimeType = dataDic["mime"] as? String, let dataLength = dataDic["length"]?.integerValue else { @@ -60,7 +60,7 @@ extension NSURL { } class func kiwixURLWithZimFileid(id: String, articleTitle: String) -> NSURL? { - guard let contentURLString = ZimMultiReader.sharedInstance.pageURLString(articleTitle, bookid: id) else { + guard let contentURLString = ZimMultiReader.shared.pageURLString(articleTitle, bookid: id) else { print("ZimMultiReader cannot get pageURLString from \(articleTitle) in book \(id)") return nil } diff --git a/Kiwix/ZimMultiReader/ZimMultiReader.swift b/Kiwix/ZimMultiReader/ZimMultiReader.swift index f4cd3502..0429318e 100644 --- a/Kiwix/ZimMultiReader/ZimMultiReader.swift +++ b/Kiwix/ZimMultiReader/ZimMultiReader.swift @@ -10,7 +10,7 @@ import CoreData import Operations class ZimMultiReader: NSObject, DirectoryMonitorDelegate { - static let sharedInstance = ZimMultiReader() + static let shared = ZimMultiReader() weak var delegate: ZimMultiReaderDelegate? private let monitor = DirectoryMonitor(URL: NSFileManager.docDirURL)