I have the following class definition in Swift:
class LandlordHome : UIViewController, UICollectionViewDelegate, UICollectionViewDataSource {
}
I'm trying to create it in F#, however the inheritance pattern in F# only allows me to inherit one class like this:
[<Register ("LandlordHome")>]
type LandlordHome (handle:IntPtr) =
inherit UIViewController (handle)
If I try to add additional classes like this:
[<Register ("LandlordHome")>]
type LandlordHome (handle:IntPtr) =
inherit UIViewController, UICollectionViewDelegate, UICollectionViewDataSource (handle)
this throws an error.
UICollectionViewDelegate
and UICollectionViewDataSource
are not class
es, but protocol
s, which are like interface
s in F#
So your could should look something like this (abstract code):
[<Register ("LandlordHome")>]
type LandlordHome (handle:IntPtr) =
inherit UIViewController (handle)
interface UICollectionViewDelegate with
// implementation of UICollectionViewDelegate
interface UICollectionViewDataSource with
// implementation of UICollectionViewDataSource