binding not implemented for this SQLType 7: Core Data and iPhone OS 3
*** Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'binding not implemented for this SQLType 7'
That’s not something you want to read. And it doesn’t make much sense. And there’s not a lot out there on that problem, either.
I am adding Core Data to Zoopcast (the people-powered local search app). The first few releases just took data from the JSON web service, and put it into unmanaged objects. (As it turns out, I probably should have gone with Core Data from day one. Despite what the docs say, it’s not that difficult. In fact, probably easier than what I was doing.)
I read that SQLType 7 is the REAL storage class in SQLite. And that storage class can handle different types of data. And I thought to myself… perhaps I am putting floats instead of doubles, somewhere in my code (which is permitted in C, and my managed objects have NSNumber properties anyway) and it’s that mapping that is getting the Core Data/SQLite layer confused.
So I had a look.
The NSDictionaries that were being decoded from JSON with JSON Framework had NSNumber objects that were NSDecimal (one of the private subclasses of NSNumber). I’m not sure if they were all NSDecimal, but they probably were: they’re stored as double precision floating point numbers in the service, and obviously have to be rounded for JSON transport, so decimal makes the most sense.
So I thought… why not force these to all be doubles, like so:
double doubleValue = [(NSNumber *)value doubleValue];<br></br> value = [NSNumber numberWithDouble:doubleValue];``` And guess what? It fixed it. This wasn’t a problem on iOS 4. It was only a problem on an iPod touch first generation running iPhone OS 3.1.3. But it’s not longer a problem for me. It was [this post on Stack Overflow](http://stackoverflow.com/questions/1200591/coredata-error-while-saving-binding-not-implemented-for-this-sqltype-7) that lead me on the right track, and Brian King’s answer actually makes perfect sense to me now that I’ve re-read it after figuring it for myself and explaining it in long form.