vendredi 24 avril 2015

Core Data Crash that redirects to the app delegate persistentStoreCoordinator mathod

Hi everyone I am trying to implement core data to a table view from my app, to avoid unwanted internet traffic the problem is that I am new to core data and also at the beginning of the implementation.

So here you have my core data Entity and how it looks:

entity model

I am using only one Entity, with the model that you can see in the photo and also with NSmanagedObjectSubclass.

What I am doing is: 1. I download an XML from the internet and I save in NSUserDefaults for better persistence, so that if the app is launched for the first time I check if the the NSUserDefaults exists than I download it again in the viewDiaAppear, and if it is for the first time I download the data in viewDidLoad. 2. So creating the data for the first Time and retrieving it in the table view works fine 3. But when the app launches for the second, It does a series of conditions at witch point it crushes during one of them witch I don't know for sure, so I added CrashLitiscs and these is what I am getting:

crash report in Crashlytics

but at the line specified I have no array, not only at that line but nothing near that line above or beneath.

These is the code at the line from Crashlytics //check ID if ([NSString stringWithFormat:@"%d", count] != suggestedEntityForGroup.groupName) { //replace with new data suggestedEntityForGroup.groupID = [NSString stringWithFormat:@"%d",count]; NSError *managedObjError = nil; if (![[self appDelegate].managedObjectContext save:&managedObjError]) { NSLog(@"Next error ocured:%@ while updating group id at position:%d", managedObjError, count); } }

And here is the entire code that handles core data DB after the XML is retrieved:

and here is the console log after the crash:

CoreData: error: -addPersistentStoreWithType:SQLite configuration:(null) URL:file:///Users/laurentiu/Library/Developer/CoreSimulator/Devices/1F02B530-AB90-4B1B-BBAA-08B3B9C14ECA/data/Containers/Data/Application/668593BE-16B2-419E-ACB9-95FB38A8A90B/Documents/ChannerApp.sqlite options:{ NSInferMappingModelAutomaticallyOption = 1; NSMigratePersistentStoresAutomaticallyOption = 1; } ... returned error Error Domain=NSCocoaErrorDomain Code=134130 "The operation couldn’t be completed. (Cocoa error 134130.)" UserInfo=0x7fa4d600ce70 {URL=file:///Users/laurentiu/Library/Developer/CoreSimulator/Devices/1F02B530-AB90-4B1B-BBAA-08B3B9C14ECA/data/Containers/Data/Application/668593BE-16B2-419E-ACB9-95FB38A8A90B/Documents/ChannerApp.sqlite, metadata={ NSPersistenceFrameworkVersion = 519; NSStoreModelVersionHashes = { Asd = <6acf157c fdf3a06b 00e10f78 074562df 987e2334 be30294e ae73e5c1 cdc1f9b1>; SuggestedChannelsEntity = ; }; NSStoreModelVersionHashesVersion = 3; NSStoreModelVersionIdentifiers = ( "" ); NSStoreType = SQLite; NSStoreUUID = "D73CCCB1-F3AE-4153-83AE-2D1B6D91E3D9"; "_NSAutoVacuumLevel" = 2; }, reason=Can't find model for source store} with userInfo dictionary { URL = "file:///Users/laurentiu/Library/Developer/CoreSimulator/Devices/1F02B530-AB90-4B1B-BBAA-08B3B9C14ECA/data/Containers/Data/Application/668593BE-16B2-419E-ACB9-95FB38A8A90B/Documents/ChannerApp.sqlite"; metadata = { NSPersistenceFrameworkVersion = 519; NSStoreModelVersionHashes = { Asd = <6acf157c fdf3a06b 00e10f78 074562df 987e2334 be30294e ae73e5c1 cdc1f9b1>; SuggestedChannelsEntity = ; }; NSStoreModelVersionHashesVersion = 3; NSStoreModelVersionIdentifiers = ( "" ); NSStoreType = SQLite; NSStoreUUID = "D73CCCB1-F3AE-4153-83AE-2D1B6D91E3D9"; "_NSAutoVacuumLevel" = 2; }; reason = "Can't find model for source store"; } 2015-04-24 17:45:34.467 ChannerApp[11021:412450] CoreData: annotation: NSPersistentStoreCoordinator's current model hashes are { SuggestedChannelsEntity = ; } 2015-04-24 17:45:34.468 ChannerApp[11021:412450] Unresolved error Error Domain=YOUR_ERROR_DOMAIN Code=9999 "Failed to initialize the application's saved data" UserInfo=0x7fa4d3c9e0c0 {NSLocalizedFailureReason=There was an error creating or loading the application's saved data., NSLocalizedDescription=Failed to initialize the application's saved data, NSUnderlyingError=0x7fa4d600e2c0 "The operation couldn’t be completed. (Cocoa error 134130.)"}, { NSLocalizedDescription = "Failed to initialize the application's saved data"; NSLocalizedFailureReason = "There was an error creating or loading the application's saved data."; NSUnderlyingError = "Error Domain=NSCocoaErrorDomain Code=134130 \"The operation couldn\U2019t be completed. (Cocoa error 134130.)\" UserInfo=0x7fa4d600ce70 {URL=file:///Users/laurentiu/Library/Developer/CoreSimulator/Devices/1F02B530-AB90-4B1B-BBAA-08B3B9C14ECA/data/Containers/Data/Application/668593BE-16B2-419E-ACB9-95FB38A8A90B/Documents/ChannerApp.sqlite, metadata={\n NSPersistenceFrameworkVersion = 519;\n NSStoreModelVersionHashes = {\n Asd = <6acf157c fdf3a06b 00e10f78 074562df 987e2334 be30294e ae73e5c1 cdc1f9b1>;\n SuggestedChannelsEntity = ;\n };\n NSStoreModelVersionHashesVersion = 3;\n NSStoreModelVersionIdentifiers = (\n \"\"\n );\n NSStoreType = SQLite;\n NSStoreUUID = \"D73CCCB1-F3AE-4153-83AE-2D1B6D91E3D9\";\n \"_NSAutoVacuumLevel\" = 2;\n}, reason=Can't find model for source store}"; }

Aucun commentaire:

Enregistrer un commentaire