Displaying Data
Displaying Data
The next step in your sample application is to actually display the data you got from Relativity Server.
NSTableView and DADataController
In your project, add a new ArrayController
and change its class to be a DADataTableController
.
The DADataTableController
class is a Data Abstract controller class designed to work with DADataTable
objects.
Add an NSTableView
to the window and configure it to have 5 columns with the names Id, Done, DueDate, Priority and Objective.
In the Binding Inspector, make sure that each column is bound to the DADataTableController
and that the Controller key is arrangedObjects and Model Key Path is set to the appropriate table field name ("Id", "Done", "DueDate", "Priority" and "Task”).
In AppDelegate.m, add and connect an Outlet
for both the NSTableView
and the DADataController
.
//AppDelegate.m
@property (weak) IBOutlet DADataTableController *tableController;
@property (weak) IBOutlet NSTableView *tableView;
NOTIFICATION_DATA_READY
Next you need to set the table
property of the DADataController
to point to the tasksTable
property of the DataAccess
object.
There is the small problem. The taskTable
property on the DataAccess
object is not going to contain a valid DADataTable
object until the data has been returned by the Relativity Server. You therefore need to ensure that the table
property of the DADataController
doesn't get set until the DataAccess
class has finish loading the data.
You do this by observing the NOTIFICATION_DATA_READY
notification that will be thrown by the DataAccess
object when it has completed the task of downloading the initial data tables.
First, add an observer for the notification in the applicationDidFinishLaunching:
method.
//AppDelegate.m
- (void)applicationDidFinishLaunching:(NSNotification *)aNotification
{
[[NSNotificationCenter defaultCenter] addObserver:self
selector:@selector(dataIsReady:)
name:NOTIFICATION_DATA_READY
object:nil];
[[DataAccess sharedInstance] setDelegate:self];
[[DataAccess sharedInstance] loadInitialData];
}
Then create the dataIsReady:
method that triggers when the notification is received and set the table
property of the DADataTableController
to the taskTable
property of the DataAccess
object.
//AppDelegate.m
-(void)dataIsReady:(NSNotification *)notification {
self.tableController.table = [[DataAccess sharedInstance] tasksTable];
}
The First Run
Now compile and run the application. After successfully logging in, you should see the main window with a grid and the single test row from the test database.