I have a CLI application that can read and write to a mysql database. I would now like to start moving this to GUI based app and the first thing i want to do is show the results of a database table to a NSTableView.
So i started by creating a new Cocoa application without any options clicked and i moved over the class.
I then edited my AdminAppDelegate.m file with the following code.
And here is were i got stuck, my only .xib is MainMenu it has a menu and a window so i put in a NSTableView and tried the trusty ctrl click to match it up with the controller as i have done with some other applications(built with the core data and document based selected) however this did not work.
Any idea where about i am going wrong, my aim for now is just to get my data on the gui instead of the console log.
So i started by creating a new Cocoa application without any options clicked and i moved over the class.
I then edited my AdminAppDelegate.m file with the following code.
Code:
#import "AB_Comforts_AdminAppDelegate.h"
#import "MysqlConnection.h"
#import "MysqlCommitException.h"
#import "MysqlRollbackException.h"
#import "GC_MYSQL_BIND.h"
#import "MysqlFetch.h"
#import "MysqlFetchField.h"
@implementation AB_Comforts_AdminAppDelegate
@synthesize window;
- (void)applicationDidFinishLaunching:(NSNotification *)aNotification {
// Connect to the database
MysqlConnection *connection = [MysqlConnection connectToHost:@"localhost"
user:@"root"
password:@""
schema:@"test_db"
flags:MYSQL_DEFAULT_CONNECTION_FLAGS];
// Fetch the users from the database
MysqlFetch *userFetch = [MysqlFetch fetchWithCommand:@"select username, email from users" onConnection:connection];
// Print out a list of users
NSLog(@"There are %d users",[userFetch.results count]);
for (NSDictionary *userRow in userFetch.results) {
NSNumber *userNumber = [userRow objectForKey: @"username"];
NSString *userName = [userRow objectForKey: @"email"];
NSLog(@"%@ %@",userNumber,userName);
}
}
@end
And here is were i got stuck, my only .xib is MainMenu it has a menu and a window so i put in a NSTableView and tried the trusty ctrl click to match it up with the controller as i have done with some other applications(built with the core data and document based selected) however this did not work.
Any idea where about i am going wrong, my aim for now is just to get my data on the gui instead of the console log.