Marcal
Marcal

Reputation: 1371

Empty string vs nil inside a core Data entity

I have an App that delivers a pre-filled sqlite database which the user can later on expand. When I built the database I set it up so that the values had to be floats (NSNumber containing floats). On some of the "cells" of the database there is no value, so I didn't fill it up.

However, when I explore the sqlite Db with the Firefox extension I see the following:

enter image description here

The "cells" I didn't fill are blue. According to the firefox extension settings, the blue "cells" indicate a String. Red indicates nil/null.

I'm trying to fetch the values of a particular attibute, filter those "Strings" and perform something like:

Entity  *entity = [[self.managedObjectContext executeFetchRequest:request error:&error] objectAtIndex:0];
[entity setValue:nil forKey:@"attribute"]; // I would do a loop for all the items in the array

However, I cannot find the way to fetch those values which seem to be a string. The only thing I could do is to select all of those whose float value is 0, but the problem is that there are actually values with 0 and it has a meaning, actually.

Any ideas on how to do that?

If I fetch everything that it's not nil, they are in there. So they are not considered null.

Upvotes: 0

Views: 842

Answers (1)

Lily Ballard
Lily Ballard

Reputation: 185731

CoreData is not a database. It is an object graph relationship manager. You're trying to do a database operation, and it isn't going to work. If you need to modify the database directly, you need to be using an actual database tool, like the SQLite library (or the sqlite3 CLI tool).

Upvotes: 1

Related Questions