I am on XCode 10, Objective-C, Mac OSX, not iOS.
I have subclassed an NSArrayController to create a new property to bind to.
SHArrayController.h
@property (nonatomic) BOOL hasItems;
SHArrayController.m
- (BOOL)hasItems
{
return ([self.arrangedObjects count] > 0);
}
If i bind anything to that property i doesn't get notified of changes. If i add an Object to the arrayController, "hasItems" should change.
This is how i add objects:
[self.arrayController willChangeValueForKey:@"hasItems"];
[self.arrayController addObject:SomeObject];
[self.arrayController didChangeValueForKey:@"hasItems"];
What am i doing wrong?
Edit: ArrayController is properly instantiated, so are the objects to add.
It was a fault of mine. The value did change and the notification works. I just made a mistake. The above implementation is correct.