nlampi / SwiftGridView

Swift based data grid view.
MIT License
58 stars 15 forks source link

Trying to programmatically create SwiftGridView crashes #46

Closed sedwo closed 5 years ago

sedwo commented 5 years ago

image

nlampi commented 5 years ago

This is generally caused when you don't have a dataSource set. Can you make sure that it is set and conforms to the SwiftGridViewDataSource protocol?

sedwo commented 5 years ago

I understand. But programmatically I need to instantiate the SwiftGridView object before I am able to set its delegates. And the crash occurs during the init process.

Crash example.

var gridDataSource = PrettyDataSource()
var gridDelegate = PrettyDelegate()

let prettyGridView = SwiftGridView(frame: CGRect(x: 0, y: 0, width: 500, height: 200))   // crash!

prettyGridView.delegate = gridDelegate
prettyGridView.dataSource = gridDataSource
sedwo commented 5 years ago

My bad. I was trying to initialize everything inside a closure.

Good job on this control. 👍

nlampi commented 5 years ago

Ah, good to have details on what situations cause errors. Thanks!