I have a potentially stupid question about a potentially stupid database design.
Let's say I have this project (in an iOS project using CoreData):
Class A
- name: NSString
- children: NSSet objects of class A
- parent: object of class A
so this is a simple parent / child setup. Everything is fine.
Now I want to make sure that if an object of class A does not define a value for "name", its parents are searched until one is found that defines a "name", and this value is returned.
This is a tricky task because my natural reaction was to override getter for this name:
- (NSString *)name
{
return name =! nil ? name : self.parent.name;
}
, "" self.name, CoreData.
nameRecursive, :
- (NSString *)nameRecursive
{
return self.name =! nil ? self.name : self.parent.name;
}
( A , ), .
- , ) .
. .