Skip to content

Instantly share code, notes, and snippets.

@chamons
Created June 9, 2015 20:30
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save chamons/607dacc1bb33c19f5100 to your computer and use it in GitHub Desktop.
Save chamons/607dacc1bb33c19f5100 to your computer and use it in GitHub Desktop.
using System;
using MonoMac.Foundation;
namespace SharpDocTest2
{
public partial class MyDocument : MonoMac.AppKit.NSDocument
{
// Called when created from unmanaged code
public MyDocument (IntPtr handle) : base (handle)
{
}
// Called when created directly from a XIB file
[Export ("initWithCoder:")]
public MyDocument (NSCoder coder) : base (coder)
{
}
[Export ("autosavesInPlace")]
new public static bool AutosavesInPlace () { return true; }
public override NSData GetAsData (string documentType, out NSError outError)
{
outError = null;
return new NSData ();
}
//
// Load support:
// Override one of ReadFromData, ReadFromFileWrapper or ReadFromUrl
//
public override bool ReadFromData (NSData data, string typeName, out NSError outError)
{
outError = null;
return true;
}
// If this returns the name of a NIB file instead of null, a NSDocumentController
// is automatically created for you.
public override string WindowNibName {
get {
return "MyDocument";
}
}
}
}
namespace Mecha.Mac
open System
open System.Collections.Generic
open MonoMac.ObjCRuntime
open MonoMac.Foundation
open MonoMac.AppKit
open MonoMac.SceneKit
[<Register("MyDocument")>]
type MyDocument =
inherit NSDocument
new (handle : IntPtr) = { inherit NSDocument (handle); }
[<Export ("initWithCoder:")>]
new (coder : NSCoder) = { inherit NSDocument (coder); }
[<Export ("autosavesInPlace")>]
static member GetAutosavesInPlace () = true
[<Export ("windowNibName")>]
member this.GetWindowNibName () =
"MyDocument"
override this.ReadFromData (data, typeName, outError) =
outError <- null
true
override this.GetAsData (typeName, outError) =
outError <- null
new NSData ()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment