public override void viewDidLoad() { base.viewDidLoad(); if (splitViewController != null) { detailViewController = (DetailViewController)(splitViewController.viewControllers().lastObject().topViewController); } _objects = new NSMutableArray(); string lDatabaseName = NSBundle.mainBundle.pathForResource("PCTrade.sqlite") ofType("db"); NSLog("%@", lDatabaseName); sqlite3 *lDatabase = null; if (sqlite3_open(lDatabaseName.cStringUsingEncoding(NSStringEncoding.NSUTF8StringEncoding), &lDatabase) == SQLITE_OK) { sqlite3_stmt *lStatement; if (sqlite3_prepare_v2(lDatabase, "select * from Customers", -1, &lStatement, null) == SQLITE_OK) { while (sqlite3_step(lStatement) == SQLITE_ROW) { var lName = (AnsiChar *)(sqlite3_column_text(lStatement, 1)); _objects.addObject(NSString.stringWithUTF8String(lName)); NSLog("row: %s", lName); } } sqlite3_close(lDatabase); } tableView.reloadData(); }
public override void viewDidLoad() { base.viewDidLoad(); // set up the (random) data to display in the collection view. // to avoid blocking the main thread and application startup, we do this in a block on a // background thread. Once done, we dispatch mach to the main thread to trigger a reload. dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), () => { var lArray = new NSMutableArray(); for (Int32 i; i <= arc4random_uniform(5) + 5; i++) { var lSection = new NSMutableArray(); for (Int32 j; j <= arc4random_uniform(50) + 5; j++) { var lSize = arc4random_uniform(100) + 100; lSection.addObject(lSize); } lArray.addObject(lSection); } data = lArray; dispatch_async(dispatch_get_main_queue(), () => collectionView.reloadData()); }); }
private void generateTestData() { tasks = new NSMutableArray(); tasks.addObject( DataLayer.newTaskWithSubject("Meeting with Kate") andPriority(9) datedBy(new NSDate())); tasks.addObject( DataLayer.newTaskWithSubject("Buy some food") andPriority(5) datedBy(new NSDate().dateByAddingTimeInterval(60 * 60 * 24 * 3))); TaskModel doneTaskSample = DataLayer.newTaskWithSubject("Fill the car") andPriority(2) datedBy(new NSDate().dateByAddingTimeInterval(60 * 60 * 24 * 2)); doneTaskSample.done = true; tasks.addObject(doneTaskSample); }