I am having an issue with ShinobiGrids SDataGridDataSourceHelper for swift, they have great examples of objective-c but not much for swift.
In objective C they create an NSObject class
@interface Student : NSObject
@property NSString *name;
@property NSNumber *credits;
@property BOOL canGraduate;
- (id)initWithName:(NSString *)name andCredits:(NSNumber *)credits canGraduate:(BOOL)canGraduate;
@end
@interface Student : NSObject
@property NSString *name;
@property NSNumber *credits;
@property BOOL canGraduate;
- (id)initWithName:(NSString *)name andCredits:(NSNumber *)credits canGraduate:(BOOL)canGraduate;
@end
and then they populate the array:
- (NSArray *)createMockStudentArray {
return @[[[Student alloc] initWithName:@"Bill" andCredits:@40 canGraduate:NO],
[[Student alloc] initWithName:@"Rob" andCredits:@80 canGraduate:YES],
[[Student alloc] initWithName:@"James" andCredits:@80 canGraduate:YES],
[[Student alloc] initWithName:@"Harry" andCredits:@30 canGraduate:NO],
[[Student alloc] initWithName:@"Sue" andCredits:@90 canGraduate:YES],
[[Student alloc] initWithName:@"Rachel" andCredits:@120 canGraduate:YES],
[[Student alloc] initWithName:@"Annie" andCredits:@70 canGraduate:NO],
[[Student alloc] initWithName:@"Daniel" andCredits:@80 canGraduate:YES],
[[Student alloc] initWithName:@"Harry" andCredits:@80 canGraduate:YES],
[[Student alloc] initWithName:@"Tom" andCredits:@90 canGraduate:YES],
[[Student alloc] initWithName:@"Fred" andCredits:@40 canGraduate:NO],
[[Student alloc] initWithName:@"Andy" andCredits:@10 canGraduate:NO],
[[Student alloc] initWithName:@"Sarah" andCredits:@60 canGraduate:NO],
[[Student alloc] initWithName:@"Elliot" andCredits:@80 canGraduate:YES],
[[Student alloc] initWithName:@"Babra" andCredits:@75 canGraduate:YES],
[[Student alloc] initWithName:@"Sam" andCredits:@110 canGraduate:YES],
[[Student alloc] initWithName:@"William" andCredits:@120 canGraduate:YES],
[[Student alloc] initWithName:@"Helen" andCredits:@90 canGraduate:YES],
[[Student alloc] initWithName:@"Jim" andCredits:@100 canGraduate:YES],
[[Student alloc] initWithName:@"Oleg" andCredits:@90 canGraduate:YES],
[[Student alloc] initWithName:@"Andrew" andCredits:@110 canGraduate:YES]];
}
and then calling it in the SDataGridDataSourceHelper settings:
SDataGridDataSourceHelper *_dataSourceHelper = [[SDataGridDataSourceHelper alloc] initWithDataGrid:_grid];
_dataSourceHelper.delegate = self;
_dataSourceHelper.data = [self createMockStudentArray];
and thats where I am having trouble with swift, I created my class:
class DataObject : NSObject
{
var lot: String
var columnA: String
var columnB: String
var columnC: String
var cameraColumn: String
init(fromString lot: String, columnA: String, columnB: String, columnC: String, cameraColumn: String) {
self.lot = lot
self.columnA = columnA
self.columnB = columnB
self.columnC = columnC
self.cameraColumn = cameraColumn
super.init()
}
}
and then populated an Array and applied it to SDataGridDataSourceHelper:
let helper = SDataGridDataSourceHelper(dataGrid: grid!)
helper?.delegate = self
var array = [DataObject.init(fromString: "lot", columnA: "colum a", columnB: "colum b", columnC: "colum c", cameraColumn: "camera")] as Array
array.append(DataObject.init(fromString: "lot", columnA: "colum a", columnB: "colum b", columnC: "colum c", cameraColumn: "camera"))
print(array)
helper?.data = array
but then I get this error when I run it and my app crashes:
this class is not key value coding-compliant for the key lot.
I have looked up this error, but all the fixes have to do with my view controller, which is empty (but has navigation controller and tap bar controller)
Am I doing something wrong? Here is the code for the project I am working off of https://github.com/shinobicontrols/grids-custom-checkbox
and this is literally everything Shinobigrids has on Swift: https://www.shinobicontrols.com/docs/ios/shinobigrids/latest/docs/markdown_files/DataGridUserGuide.html#Quick Start Guide - Swift