зеркало из https://github.com/mono/mail-archives.git
143 строки
3.5 KiB
HTML
143 строки
3.5 KiB
HTML
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2//EN">
|
|
<HTML>
|
|
<HEAD>
|
|
<TITLE> [Mono-osx] [MonoMac] shared NSDocument
|
|
</TITLE>
|
|
<LINK REL="Index" HREF="index.html" >
|
|
<LINK REL="made" HREF="mailto:mono-osx%40lists.ximian.com?Subject=%5BMono-osx%5D%20%5BMonoMac%5D%20shared%20NSDocument&In-Reply-To=">
|
|
<META NAME="robots" CONTENT="index,nofollow">
|
|
<META http-equiv="Content-Type" content="text/html; charset=us-ascii">
|
|
<LINK REL="Previous" HREF="003695.html">
|
|
<LINK REL="Next" HREF="003863.html">
|
|
</HEAD>
|
|
<BODY BGCOLOR="#ffffff">
|
|
<H1>[Mono-osx] [MonoMac] shared NSDocument</H1>
|
|
<B>Duane Wandless</B>
|
|
<A HREF="mailto:mono-osx%40lists.ximian.com?Subject=%5BMono-osx%5D%20%5BMonoMac%5D%20shared%20NSDocument&In-Reply-To="
|
|
TITLE="[Mono-osx] [MonoMac] shared NSDocument">duane at wandless.net
|
|
</A><BR>
|
|
<I>Sun Jan 16 11:02:41 EST 2011</I>
|
|
<P><UL>
|
|
<LI>Previous message: <A HREF="003695.html">[Mono-osx] [MonoMac] Pragmatic's Core Animation for Mac OS X - Chapter 7
|
|
</A></li>
|
|
<LI>Next message: <A HREF="003863.html">[Mono-osx] MonoMacPackager - No CreateMacInstaller Option in MonoDevelop
|
|
</A></li>
|
|
<LI> <B>Messages sorted by:</B>
|
|
<a href="date.html#3671">[ date ]</a>
|
|
<a href="thread.html#3671">[ thread ]</a>
|
|
<a href="subject.html#3671">[ subject ]</a>
|
|
<a href="author.html#3671">[ author ]</a>
|
|
</LI>
|
|
</UL>
|
|
<HR>
|
|
<!--beginarticle-->
|
|
<PRE>I'm trying to create a Document based app. I need to share MyDocument
|
|
across multiple view controller NIBs. So in each NIB I add an NSDocument
|
|
object then change the class to be MyDocument. As each VC is loaded a new
|
|
MyDocument object is created. However this is incorrect we want the initial
|
|
MyDocument object to be used. In the obj-c app we have this is being done:
|
|
|
|
static MyDocument* sharedDocument;
|
|
|
|
|
|
- (id)init
|
|
|
|
{
|
|
|
|
if(!sharedDocument)
|
|
|
|
{
|
|
|
|
self = [super init];
|
|
|
|
if (self != nil) {
|
|
|
|
sharedDocument=self;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return sharedDocument;
|
|
|
|
}
|
|
|
|
|
|
+(MyDocument*)sharedDocument
|
|
|
|
{
|
|
|
|
if(!sharedDocument)
|
|
|
|
{
|
|
|
|
[[MyDocument alloc] init];
|
|
|
|
}
|
|
|
|
return sharedDocument;
|
|
|
|
}
|
|
|
|
And here is how I implemented this. I'm not sure if this is the best
|
|
solution. I'm concerned there will be a leak, though I have not looked yet.
|
|
Any suggestions are appreciated.
|
|
|
|
public MyDocument (IntPtr handle) : base(SharedDocument == null ? handle :
|
|
SharedDocument.Handle)
|
|
{
|
|
if (SharedDocument == null)
|
|
{
|
|
SharedDocument = this;
|
|
}
|
|
}
|
|
|
|
|
|
Thanks,
|
|
Duane
|
|
-------------- next part --------------
|
|
An HTML attachment was scrubbed...
|
|
URL: <A HREF="http://lists.ximian.com/pipermail/mono-osx/attachments/20110116/5a5204c9/attachment.html">http://lists.ximian.com/pipermail/mono-osx/attachments/20110116/5a5204c9/attachment.html</A>
|
|
</PRE>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<!--endarticle-->
|
|
<HR>
|
|
<P><UL>
|
|
<!--threads-->
|
|
<LI>Previous message: <A HREF="003695.html">[Mono-osx] [MonoMac] Pragmatic's Core Animation for Mac OS X - Chapter 7
|
|
</A></li>
|
|
<LI>Next message: <A HREF="003863.html">[Mono-osx] MonoMacPackager - No CreateMacInstaller Option in MonoDevelop
|
|
</A></li>
|
|
<LI> <B>Messages sorted by:</B>
|
|
<a href="date.html#3671">[ date ]</a>
|
|
<a href="thread.html#3671">[ thread ]</a>
|
|
<a href="subject.html#3671">[ subject ]</a>
|
|
<a href="author.html#3671">[ author ]</a>
|
|
</LI>
|
|
</UL>
|
|
|
|
<hr>
|
|
<a href="http://lists.ximian.com/mailman/listinfo/mono-osx">More information about the Mono-osx
|
|
mailing list</a><br>
|
|
</body></html>
|