nlampi / SwiftGridView

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

Implemention in ObjC #58

Closed NishantSingh47 closed 3 years ago

NishantSingh47 commented 3 years ago

I am trying to use the GridView in a ObjC project. I did the relevant changes in the SwiftGridView.swift, DataSource and Delegate.swift files and am able to compile. But how to create the cells and header/footer views, you can't subclass Swift Class to ObjC. I tried copying the BasicNib/Text Cells/Views from the Example Project, but getting error while importing them.

import "BasicNibCell-Swift.h" --> Error: Unable to find the file

@nlampi

nlampi commented 3 years ago

Hi @NishantSingh47, I haven't done much testing in ObjC before which has caused the issues you have seen. I have created a branch with some changes to allow ObjC to function, but it has a few caveats and needs more testing but looks good so far. In the objc branch I have made the necessary objc additions to the base SwiftGridView class. In the examples I have added an ObjC based project to continue testing with. The issues are as you mentioned that subclassing Swift in ObjC doesn't work and also using extensions on a struct (IndexPath). For this I added a category in the project to correctly map the NSIndexPath. For the cells and reusable views, the only thing that can be done due to type checks is to implement those in Swift. To reference the cells in ObjC code you will need to import the module header in the ObjC file (by default it is ProjectName-Swift.h). You can use this branch in the short term as experimental while testing is being done to confirm a stable release.

NishantSingh47 commented 3 years ago

Thanks alot @nlampi for taking out time. The changes seems to be working fine for me now. I had updated my Product Name sometime back and while importing the header was referring to older name. I would too test this branch and update incase any issues crop up with possible fixes :)

nlampi commented 3 years ago

Merged all objc changes into the latest release 0.7.4