Commit 534d9dce authored by Kliative's avatar Kliative

Open Exchange Offline [Core Data], I think it won't crash now haha

parent 3b5d74f6
......@@ -36,6 +36,7 @@
7A1DBEBE1EED802600790B54 /* Bariol_Thin_Italic.otf in Resources */ = {isa = PBXBuildFile; fileRef = 7A1DBEB71EED802600790B54 /* Bariol_Thin_Italic.otf */; };
7A1DBEBF1EED802600790B54 /* Bariol_Thin.otf in Resources */ = {isa = PBXBuildFile; fileRef = 7A1DBEB81EED802600790B54 /* Bariol_Thin.otf */; };
7A1DBEC11EF172BE00790B54 /* CityCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7A1DBEC01EF172BE00790B54 /* CityCell.swift */; };
7A382FF41F9507680061762B /* QuantoCoreData.xcdatamodeld in Sources */ = {isa = PBXBuildFile; fileRef = 7A382FF21F9507680061762B /* QuantoCoreData.xcdatamodeld */; };
7A75586F1EF684E500EC2396 /* LaunchScreen.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 7A75586D1EF684E500EC2396 /* LaunchScreen.storyboard */; };
7AF443221F066A6E006C8958 /* OnBoarding.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7AF443211F066A6E006C8958 /* OnBoarding.swift */; };
7AF443261F066C24006C8958 /* OnBoardingVC.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7AF443251F066C24006C8958 /* OnBoardingVC.swift */; };
......@@ -96,6 +97,7 @@
7A1DBEB71EED802600790B54 /* Bariol_Thin_Italic.otf */ = {isa = PBXFileReference; lastKnownFileType = file; path = Bariol_Thin_Italic.otf; sourceTree = "<group>"; };
7A1DBEB81EED802600790B54 /* Bariol_Thin.otf */ = {isa = PBXFileReference; lastKnownFileType = file; path = Bariol_Thin.otf; sourceTree = "<group>"; };
7A1DBEC01EF172BE00790B54 /* CityCell.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = CityCell.swift; sourceTree = "<group>"; };
7A382FF31F9507680061762B /* QuantoCoreData.xcdatamodel */ = {isa = PBXFileReference; lastKnownFileType = wrapper.xcdatamodel; path = QuantoCoreData.xcdatamodel; sourceTree = "<group>"; };
7A75586E1EF684E500EC2396 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Quanto/Base.lproj/LaunchScreen.storyboard; sourceTree = "<group>"; };
7A849D5D1F14E3C700079161 /* Quanto.entitlements */ = {isa = PBXFileReference; lastKnownFileType = text.plist.entitlements; path = Quanto.entitlements; sourceTree = "<group>"; };
7AF443211F066A6E006C8958 /* OnBoarding.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = OnBoarding.swift; sourceTree = "<group>"; };
......@@ -177,6 +179,7 @@
7A75586D1EF684E500EC2396 /* LaunchScreen.storyboard */,
083AF8581E9F9A3F00AE5445 /* Info.plist */,
7A111ED61EF812A40042ED78 /* GoogleService-Info.plist */,
7A382FF21F9507680061762B /* QuantoCoreData.xcdatamodeld */,
);
path = Quanto;
sourceTree = "<group>";
......@@ -637,6 +640,7 @@
7AF443261F066C24006C8958 /* OnBoardingVC.swift in Sources */,
7A111EDD1EF8165F0042ED78 /* DestCurrVC.swift in Sources */,
7A111ED51EF811650042ED78 /* ExchangeService.swift in Sources */,
7A382FF41F9507680061762B /* QuantoCoreData.xcdatamodeld in Sources */,
7A1DBEC11EF172BE00790B54 /* CityCell.swift in Sources */,
7A111EDF1EF816720042ED78 /* BaseCurrVC.swift in Sources */,
083AF84D1E9F9A3F00AE5445 /* AppDelegate.swift in Sources */,
......@@ -925,6 +929,19 @@
defaultConfigurationName = Release;
};
/* End XCConfigurationList section */
/* Begin XCVersionGroup section */
7A382FF21F9507680061762B /* QuantoCoreData.xcdatamodeld */ = {
isa = XCVersionGroup;
children = (
7A382FF31F9507680061762B /* QuantoCoreData.xcdatamodel */,
);
currentVersion = 7A382FF31F9507680061762B /* QuantoCoreData.xcdatamodel */;
path = QuantoCoreData.xcdatamodeld;
sourceTree = "<group>";
versionGroupType = wrapper.xcdatamodel;
};
/* End XCVersionGroup section */
};
rootObject = 083AF8411E9F9A3E00AE5445 /* Project object */;
}
......@@ -11,6 +11,7 @@ import Firebase
import UserNotifications
import FirebaseInstanceID
import FirebaseMessaging
import CoreData
@UIApplicationMain
class AppDelegate: UIResponder, UIApplicationDelegate, UNUserNotificationCenterDelegate, FIRMessagingDelegate {
......@@ -79,13 +80,61 @@ class AppDelegate: UIResponder, UIApplicationDelegate, UNUserNotificationCenterD
// Restart any tasks that were paused (or not yet started) while the application was inactive. If the application was previously in the background, optionally refresh the user interface.
}
func applicationReceivedRemoteMessage(_ remoteMessage: FIRMessagingRemoteMessage) {
print(" -- -- \(remoteMessage.appData)")
}
func applicationWillTerminate(_ application: UIApplication) {
// Called when the application is about to terminate. Save data if appropriate. See also applicationDidEnterBackground:.
// Saves changes in the application's managed object context before the application terminates.
self.saveContext()
}
func applicationReceivedRemoteMessage(_ remoteMessage: FIRMessagingRemoteMessage) {
print(" -- -- \(remoteMessage.appData)")
// MARK: - Core Data stack
lazy var persistentContainer: NSPersistentContainer = {
/*
The persistent container for the application. This implementation
creates and returns a container, having loaded the store for the
application to it. This property is optional since there are legitimate
error conditions that could cause the creation of the store to fail.
*/
let container = NSPersistentContainer(name: "QuantoCoreData")
container.loadPersistentStores(completionHandler: { (storeDescription, error) in
if let error = error as NSError? {
// Replace this implementation with code to handle the error appropriately.
// fatalError() causes the application to generate a crash log and terminate. You should not use this function in a shipping application, although it may be useful during development.
/*
Typical reasons for an error here include:
* The parent directory does not exist, cannot be created, or disallows writing.
* The persistent store is not accessible, due to permissions or data protection when the device is locked.
* The device is out of space.
* The store could not be migrated to the current model version.
Check the error message to determine what the actual problem was.
*/
fatalError("Unresolved error \(error), \(error.userInfo)")
}
})
return container
}()
// MARK: - Core Data Saving support
func saveContext () {
let context = persistentContainer.viewContext
if context.hasChanges {
do {
try context.save()
} catch {
// Replace this implementation with code to handle the error appropriately.
// fatalError() causes the application to generate a crash log and terminate. You should not use this function in a shipping application, although it may be useful during development.
let nserror = error as NSError
fatalError("Unresolved error \(nserror), \(nserror.userInfo)")
}
}
}
}
let ad = UIApplication.shared.delegate as! AppDelegate
let context = ad.persistentContainer.viewContext
This diff is collapsed.
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment