Convert NSString to NSNumber when importing #334

merged 4 commits into from Jan 25, 2013


None yet

6 participants



I am working with an app that needs to import data from a Rest API. Everything looks OK, however when importing the data I see some fields in the database that are declared as numbers but the server side gives them inside "", which will consider them a string.

Current result:

The importation fails, and none of the data is imported


I implemented a new check in the NSAttributeDescription+MagicalDataImport that, in case of expecting any type of integer, checks if the data is a NSNumber, and if not it tries to convert it.
I also included the unit tests related to it.

Result with the fix:

Strings are converted to numbers when needed, and therefore the data importation works as expected.

I hope you find everything OK and can me merged quickly.

berikv commented Dec 7, 2012

Seems sensible to me.

xslim commented Dec 7, 2012

I vote for adding this.


Please add it!

jstart commented Jan 21, 2013



Apologies for being behind on this one. I'll talk this over with the team, but first impressions for me are pretty good. Thanks for sending this in!

@casademora casademora merged commit 435da59 into magicalpanda:develop Jan 25, 2013
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment