Open EckyZero opened 10 years ago
Could you also please post the fetch request you're creating? (the code would be best).
Of course. Here it is:
AFJSONRequestOperation *operation = [AFJSONRequestOperation JSONRequestOperationWithRequest:request success:^(NSURLRequest *request, NSHTTPURLResponse *response, id JSON) {
[MagicalRecord saveWithBlock:^(NSManagedObjectContext *localContext) {
NSArray *array = [NSArray arrayWithArray:JSON[@"receipts"]];
for(NSDictionary *dictionary in array) {
[Receipt MR_importFromObject:dictionary inContext:localContext];
}
}
} completion:^(BOOL success, NSError *error) {
success([Receipt MR_findAll]);
}];
} failure:^(NSURLRequest *request, NSHTTPURLResponse *response, NSError *error, id JSON) {
failure(error);
}];
On a side note, [Receipt MR_importFromArray:array] doesn't work for me. Thus, I'm iterating through each NSDictionary in the array and calling MR_importFromObject:
Also, the version I'm using is MagicalRecord (2.2)
Would you mind giving the current version in develop
or the latest released beta a go and see if the array import and the exception you're seeing are still occurring there? Thanks!
I posted this issue on StackOverflow here (http://stackoverflow.com/questions/23207544/magicalrecord-nsdate-in-relatedbyattribute#comment35517876_23207544) and was directed to include the full details in this issue tracker. Essentially, I have an object where the only unique identifier for the object is an NSDate. As such, I'd like to use an NSDate attribute as the primary key for my object. Here's the full backtrace/error when I try to do so:
2014-04-22 08:29:05.475 NUSVolumesModuleApp[699:60b] +NSManagedObjectContext(MagicalRecord) MR_contextWithStoreCoordinator: -> Created Context UNNAMED 2014-04-22 08:29:05.477 NUSVolumesModuleApp[699:60b] +NSManagedObjectContext(MagicalRecord) MR_setRootSavingContext: Set Root Saving Context: <NSManagedObjectContext: 0x1701db6c0> 2014-04-22 08:29:05.479 NUSVolumesModuleApp[699:60b] +NSManagedObjectContext(MagicalRecord) MR_newMainQueueContext Created Main Queue Context: <NSManagedObjectContext: 0x1701db7b0> 2014-04-22 08:29:05.480 NUSVolumesModuleApp[699:60b] +NSManagedObjectContext(MagicalRecord) MR_setDefaultContext: Set Default Context: <NSManagedObjectContext: 0x1701db7b0> 2014-04-22 08:29:05.481 NUSVolumesModuleApp[699:60b] -NSManagedObjectContext(MagicalSaves) MR_saveWithOptions:completion: NO CHANGES IN * DEFAULT * CONTEXT - NOT SAVING 2014-04-22 08:29:06.774 NUSVolumesModuleApp[699:3507] -[NSCFString timeIntervalSinceReferenceDate]: unrecognized selector sent to instance 0x178025480 2014-04-22 08:30:00.304 NUSVolumesModuleApp[699:3507] *\ Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[NSCFString timeIntervalSinceReferenceDate]: unrecognized selector sent to instance 0x178025480' *\ First throw call stack: (0x18680e950 0x192d141fc 0x186813604 0x186811330 0x18673108c 0x1864f9aac 0x1865f1740 0x1865017b0 0x186501324 0x186500eb0 0x1864feeb0 0x1865a3500 0x1865a3d7c 0x1932ebfd4 0x1932f1c84 0x186598cec 0x1865a3a0c 0x1864feeb0 0x1000ab314 0x18659b474 0x18659b614 0x1000ab178 0x1000ab5ec 0x1000a8d94 0x1000a5df0 0x1000a77f4 0x1000a6ff8 0x1000a6d7c 0x1000a7600 0x1000a773c 0x1000a7b54 0x10004fef4 0x1000a0e68 0x18659b544 0x1932ebfd4 0x1932f24a8 0x1932ee4c0 0x1932f30f4 0x1932f34fc 0x1934816bc 0x19348154c) libc++abi.dylib: terminating with uncaught exception of type NSException