mercredi 2 septembre 2015

How does Core Data optional attribute of entity work?

I’m trying to set an entity attribute to be not null by setting it to be none-optional.

But when I assign the attribute nil in test case, it reports no error or exception and the test succeeded. And by the way, how can I make sure this attribute is not optional with unit testing?

Baby *baby = [self.babyModel createWithName:nil];
XCTAssertNil(baby.name);

And when I check the schema of the table in sqlite, it doesn’t set it to be not null. Does that mean this constraint is guaranteed by core data stack instead of sqlite?

Aucun commentaire:

Enregistrer un commentaire