Attachment: Program.fs
Description: Binary data

Attachment: Controller.fs
Description: Binary data

Attachment: AssemblyInfo.fs
Description: Binary data


Hello,

I have now managed to rewrite the ToolbarSample using F# and it seems to work perfectly.

There is however an issue with member fields and F#: F# compiles "fields" to IL-fields with an prefix underscore. In order to complete the rewrite I added a new constructor to ObjectiveCFieldAttribute that takes the name of the field to bind:

        public ObjectiveCFieldAttribute(String name)
        {
            this.name = name;
        }


So to translate the following (member field-)snippet from C#:

    [ObjectiveCField]
    public NSWindow theWindow;

to F#:

    [<DefaultValue>]
    [<ObjectiveCField("theWindow")>
    val mutable theWindow:NSWindow

(I think it is generally a good thing to be able to explicitly bind a .Net-field to any ObjC field you like so I believe this addition is useful even outside the scope of F#.)

This was the only change I had to make to the Monobjc code.

I do not mind sharing the code as it is right now but will spend some time cleaning it up and make it more F#-ish - as it is now it is a plain translation of the C#-code. The current state of the code is attached - if the list manager let it through.

Regards,
Johan Kullbom

Reply via email to