Core Core to iOS ratio: use the option with or without a minimum

In the master data, you can set the relation to optional, but you can set it with little or no control ... Check the images below for a difference. Which I think I noticed that when searching for an object using a predicate like: @"object != %@", objectToSearchFor , the first parameter returns zero, but the second parameter does not. I may be wrong about this, but does anyone know the difference between the two settings?

Optional relationship without minimum

Optional relationship with minimum

Ps I do not know if this matters, but I use SQLite as a database engine.

+4
source share
1 answer

There is some documentation in the NSRelationshipDescription Class Reference documentation:

Cardinality
The maximum and minimum values ​​for the relationship indicate the number of objects that are referenced (1 for one, the ratio -1 means undefined). The calculations are performed only if the value of the relation in the containing object is not equal to zero. That is, provided that the value of the relation is optional, objects in relations that can be less than the minimum number can be equal to zero.

So, for example, in the case of an optional to-many relationship: the value of the relationship must be either nil , or contain at least the minimum number of required objects.

In the case of the “optional to one” relationship, the value of the relationship is either nil or points to another object, so I can’t think of a situation where it matters whether the minimum count is 0 or 1.

All restrictions, such as the minimum and maximum number, etc., are checked while maintaining the context of the managed entity.

+4
source

All Articles