I am trying to create a preference pane which will reside within system preferences. All the bindings are done as usual (for a normal windowed application), but when the setter for the binding property is called (data is updated), the table data does not reset. Are preference panes capable of updating table data via bindings? I have also tried to use a table data source unsuccessfully.
To clarify, I have an NSMutableArray property in my prefPane's main class, an object representing the prefPane's main class, and an arrayController in IB which is bound to the table column. in the init method of the prefPane's main class, I set the value of the NSMutableArray, which is properly reflected in the pref pane, however, (just to test if bindings work), i have an NSTimer which resets the value of my NSMutable array when it finishes. A console message tells me that the value is properly reset, however, the changes are not reflected in the pref pane.
So in my current version i use the following code to set the properties to arbitrary values (simplified to try to get bindings to work at all). The property value is then reset by a timer 10 seconds later. Although the property is correctly updated (verified by console log), the pref pane does not reflect the changes in the tableview. Unfortunately, I cannot post screenshots of the bindings. I have an object in IB for the syncFrontEndPref class. I then have an arraycontroller bound to this object w/ a model key path of listArray. Then my table column is bound to the arraycontroller arranged objects. This loads properly with "test", "test1", "test2" in the pref pane (as populated from the init method). However, when repopulated from the timer, the changes are not reflected in the pref pane (although console log confirms listArray has indeed changed.
Here is the code:
@interface syncFrontEndPref : NSPreferencePane
{
NSMutableArray *listArray;
NSNumber *syncInt;
AuthenticateUser *newUser;
NSMutableArray *syncIntervalList;
IBOutlet NSTableView *theTableView;
}
@property (retain) NSMutableArray *listArray;
@property (retain) NSMutableArray *syncIntervalList;
- (void) mainViewDidLoad;
-(IBAction)syncIntervalValueChanged:(id)sender;
-(IBAction)tableViewSelected:(id)sender;
@implementation syncFrontEndPref
@synthesize listArray, syncIntervalList;
-(id) init{
//populate nsarray w/ list data to display
//[self setListArray: [NSMutableArray arrayWithArray:[[[NSDictionary dictionaryWithContentsOfFile:[GetFilePath pathForFile]] objectForKey:@"lists"] allObjects]]];
[self setListArray: [NSMutableArray arrayWithObjects: @"test", @"test1", @"test2", nil]];
//define values for drop-down sync interval selector
[self setSyncIntervalList:[NSMutableArray arrayWithObjects: @"1 minute", @"5 minutes", @"10 minutes", @"30 minutes", @"24 hours", nil]];
return self;
}
//code for the timer and selector method
- (void) mainViewDidLoad{
NSTimer *timer = [[NSTimer new] autorelease];
int syncTime = 10;
timer = [NSTimer scheduledTimerWithTimeInterval: syncTime target:self selector:@selector(targetMethod:) userInfo:nil repeats: YES];
}
-(void)targetMethod:(id)sender{
NSLog(@"running timer...");
[self setListArray: [NSMutableArray arrayWithObjects: @"0", @"1", @"2", nil]];
NSLog(@"%@", listArray);
}