How would I translate the following C# code into F#:
public class AnimalCell : UICollectionViewCell
{
[Export ("initWithFrame:")]
public AnimalCell (RectangleF frame) : base (frame) {}
}
I tried following the example in the below link, however, I do not know how to proceed next: Overriding Constructors in F#
What I have come up with up till now is this:
[<Register ("AnimalCell")>]
type AnimalCell (handle: IntPtr) as this =
inherit UICollectionViewCell (handle)
where would I add the Export as well as the parameters? I know I should use new() but I'm not sure how to proceed.
Something like this will get you started:
F# UICollectionViewCell subclass[<Register ("AnimalCell")>]
type AnimalCell =
inherit UICollectionViewCell
[<DefaultValue>] static val mutable private id : NSString
static member init =
printfn "Initializing AnimalCell."
AnimalCell.id <- new NSString("animalCell")
[<Export("init")>]
new() = { inherit UICollectionViewCell() } then AnimalCell.init
[<Export("initWithFrame:")>]
new(frame: CGRect) = { inherit UICollectionViewCell(frame) } then AnimalCell.init
[<Export("initWithCoder:")>]
new(coder: NSCoder) = { inherit UICollectionViewCell(coder) } then AnimalCell.init
new(handle: IntPtr) = { inherit UICollectionViewCell(handle) } then AnimalCell.init
override this.ReuseIdentifier = AnimalCell.id
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With