Skip to content


Subversion checkout URL

You can clone with
Download ZIP


Fixed crashing when importing data with a different than expected type #243

wants to merge 1 commit into from

3 participants



Started using MagicalImport on a new project and run into an error: when importing data with another type than it is expected in the entity's setter an exception is thrown - for example, if you put NSNumber into - (void)setTitle:(NSString *)title. It would be good to check such kind of errors when importing data from REST API. Changing the data type on the server side would crash the whole app.

I've added try-catch block on setting KVC value. I doubt that it is the best implementation regarding performance issues but it solves the problem.

Would like to hear your thoughts on this.

Thank you.


As soon as we get a test for this I can merge.
I'm also leery to do try/catch, but don't have another foolproof solution

@blackgold9 blackgold9 was assigned

Yes. Are you willing to do it?

@blackgold9 blackgold9 closed this
@blackgold9 blackgold9 reopened this



Closing due to lack of activity. Please feel free to re-open this issue if it’s still relevant, or if you can give me some guidance on writing a test to ensure the function of this change.

@tonyarnold tonyarnold closed this
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
This page is out of date. Refresh to see the latest.
7 MagicalRecord/Categories/NSManagedObject/NSManagedObject+MagicalDataImport.m
@@ -51,7 +51,12 @@ - (void) MR_setAttributes:(NSDictionary *)attributes forKeysWithDictionary:(id)o
id value = [attributeInfo MR_valueForKeyPath:lookupKeyPath fromObjectData:objectData];
if (![self MR_importValue:value forKey:attributeName])
- [self setValue:value forKey:attributeName];
+ @try {
+ [self setValue:value forKey:attributeName];
+ }
+ @catch (NSException *exception) {
+ NSLog(@"Couldn't import value: %@", exception.reason);
+ }
Something went wrong with that request. Please try again.