I’m trying to create a view-based NSTableView, populated via Cocoa bindings.
My NSArrayController is pointing to the jobs
array property of the currentUser
property of the application delegate, like so:
I expect each model in that array to be of class HSJob
:
However, once I’m binding my table view to the NSArrayController, its arrangedObjects
property for some reason thinks it belongs to class HSJob
(I’m expecting an NSArray
).
Obviously, this doesn’t let me link individual cell content to Job object properties and I can’t display anything in my table view:
So what am I doing wrong here?
Update
I even decided to go as far as implementing some manual value update notifications + moving everything into the AppDelegate, just to experiment. Here, I changed my own HSJob
class for just some NSDictionaries.
AppDelegate.h
@property NSArray *things;
AppDelegate.m
@synthesize things = _things;
- (NSArray *)things {
if (!_things)
return @[@{@"name": @"Default Thing"}];
else
return _things;
}
- (void)setThings:(NSArray *)things {
[self willChangeValueForKey:@"things"];
_things = things;
[self didChangeValueForKey:@"things"];
}
- (void)applicationDidFinishLaunching:(NSNotification *)aNotification {
[self setThings:@[@{@"name": @"Actual Thing"}]];
}
Only “Default Thing” ever gets displayed. Even though I’m setting a new value to the things
property right after the application launch, that array never gets displayed.