You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

88 lines
3.6 KiB

2 months ago
2 months ago
2 months ago
  1. //
  2. // AppDelegate.m
  3. // HC
  4. //
  5. // Created by huilinLi on 2025/11/17.
  6. //
  7. #import "AppDelegate.h"
  8. #import "ViewController.h"
  9. #import "ChartViewController.h"
  10. @interface AppDelegate ()
  11. @end
  12. @implementation AppDelegate
  13. - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
  14. #if DEBUG
  15. [[NSBundle bundleWithPath:@"/Applications/InjectionIII.app/Contents/Resources/iOSInjection.bundle"] load];
  16. #endif
  17. return YES;
  18. }
  19. #pragma mark - UISceneSession lifecycle
  20. - (UISceneConfiguration *)application:(UIApplication *)application configurationForConnectingSceneSession:(UISceneSession *)connectingSceneSession options:(UISceneConnectionOptions *)options {
  21. // Called when a new scene session is being created.
  22. // Use this method to select a configuration to create the new scene with.
  23. return [[UISceneConfiguration alloc] initWithName:@"Default Configuration" sessionRole:connectingSceneSession.role];
  24. }
  25. - (void)application:(UIApplication *)application didDiscardSceneSessions:(NSSet<UISceneSession *> *)sceneSessions {
  26. // Called when the user discards a scene session.
  27. // If any sessions were discarded while the application was not running, this will be called shortly after application:didFinishLaunchingWithOptions.
  28. // Use this method to release any resources that were specific to the discarded scenes, as they will not return.
  29. }
  30. #pragma mark - Core Data stack
  31. @synthesize persistentContainer = _persistentContainer;
  32. - (NSPersistentContainer *)persistentContainer {
  33. // The persistent container for the application. This implementation creates and returns a container, having loaded the store for the application to it.
  34. @synchronized (self) {
  35. if (_persistentContainer == nil) {
  36. _persistentContainer = [[NSPersistentContainer alloc] initWithName:@"HC"];
  37. [_persistentContainer loadPersistentStoresWithCompletionHandler:^(NSPersistentStoreDescription *storeDescription, NSError *error) {
  38. if (error != nil) {
  39. // Replace this implementation with code to handle the error appropriately.
  40. // abort() 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.
  41. /*
  42. Typical reasons for an error here include:
  43. * The parent directory does not exist, cannot be created, or disallows writing.
  44. * The persistent store is not accessible, due to permissions or data protection when the device is locked.
  45. * The device is out of space.
  46. * The store could not be migrated to the current model version.
  47. Check the error message to determine what the actual problem was.
  48. */
  49. NSLog(@"Unresolved error %@, %@", error, error.userInfo);
  50. abort();
  51. }
  52. }];
  53. }
  54. }
  55. return _persistentContainer;
  56. }
  57. #pragma mark - Core Data Saving support
  58. - (void)saveContext {
  59. NSManagedObjectContext *context = self.persistentContainer.viewContext;
  60. NSError *error = nil;
  61. if ([context hasChanges] && ![context save:&error]) {
  62. // Replace this implementation with code to handle the error appropriately.
  63. // abort() 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.
  64. NSLog(@"Unresolved error %@, %@", error, error.userInfo);
  65. abort();
  66. }
  67. }
  68. @end