mail-archives/mono-osx/2011-July/004446.html

103 строки
4.0 KiB
HTML

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2//EN">
<HTML>
<HEAD>
<TITLE> [Mono-osx] How to pass nil?
</TITLE>
<LINK REL="Index" HREF="index.html" >
<LINK REL="made" HREF="mailto:mono-osx%40lists.ximian.com?Subject=%5BMono-osx%5D%20How%20to%20pass%20nil%3F&In-Reply-To=8F7649E4-6735-492B-979A-3C74E6AE815E%40tarkvara.org">
<META NAME="robots" CONTENT="index,nofollow">
<META http-equiv="Content-Type" content="text/html; charset=us-ascii">
<LINK REL="Previous" HREF="004445.html">
<LINK REL="Next" HREF="004447.html">
</HEAD>
<BODY BGCOLOR="#ffffff">
<H1>[Mono-osx] How to pass nil?</H1>
<B>kjpou</B>
<A HREF="mailto:mono-osx%40lists.ximian.com?Subject=%5BMono-osx%5D%20How%20to%20pass%20nil%3F&In-Reply-To=8F7649E4-6735-492B-979A-3C74E6AE815E%40tarkvara.org"
TITLE="[Mono-osx] How to pass nil?">kjpou at pt.lu
</A><BR>
<I>Sun Jul 31 05:29:10 EDT 2011</I>
<P><UL>
<LI>Previous message: <A HREF="004445.html">[Mono-osx] How to pass nil?
</A></li>
<LI>Next message: <A HREF="004447.html">[Mono-osx] How to pass nil?
</A></li>
<LI> <B>Messages sorted by:</B>
<a href="date.html#4446">[ date ]</a>
<a href="thread.html#4446">[ thread ]</a>
<a href="subject.html#4446">[ subject ]</a>
<a href="author.html#4446">[ author ]</a>
</LI>
</UL>
<HR>
<!--beginarticle-->
<PRE>Eric
If the parameter you are passing can be Null as per the docs then the
bindings should be changed to reflect that.
When you find the parameter that can be null you will have to specify
[NullAllowed] for the parameter.
Example:
[Export (&quot;colorUsingColorSpaceName:&quot;)]
NSColor UsingColorSpace ([NullAllowed] string colorSpaceName);
The parameter colorSpaceName can be pass a null value so the parameter
is marked as [NullAllowed] in the method declaration.
For properties you can do the same thing.
Example:
[Export (&quot;target&quot;), NullAllowed]
NSObject Target { get; set; }
The Target property accepts null values so for the Property definition
you specify the NullAllowed attribute in the Export.
Kenneth
On 7/31/11 4:53 AM, Eric J. M. Smith wrote:
&gt;<i> Greetings,
</I>&gt;<i>
</I>&gt;<i> Another newbie question about the MonoMac bindings.
</I>&gt;<i>
</I>&gt;<i> I've found that a couple of methods throw an &quot;Argument cannot be null&quot; error even though the Apple docs state that they should be able to take nil as an argument. I take it that it is a limitation of the current MonoMac bindings. Given that, what's the best way to deal with this?
</I>&gt;<i>
</I>&gt;<i> For some cases, the ugly solution of allocating a temporary object (e.g. :myWindow.OrderOut(new NSObject())&quot;) seems to work. But for other methods, a nil parameter has a special significance in the API... what's the best practice for passing nil in those cases?
</I>&gt;<i>
</I>&gt;<i> Thanks,
</I>&gt;<i>
</I>&gt;<i> Eric Smith
</I>&gt;<i> Tarkvara Design Inc.
</I>&gt;<i> _______________________________________________
</I>&gt;<i> Mono-osx mailing list
</I>&gt;<i> <A HREF="http://lists.ximian.com/mailman/listinfo/mono-osx">Mono-osx at lists.ximian.com</A>
</I>&gt;<i> <A HREF="http://lists.ximian.com/mailman/listinfo/mono-osx">http://lists.ximian.com/mailman/listinfo/mono-osx</A>
</I>&gt;<i>
</I></PRE>
<!--endarticle-->
<HR>
<P><UL>
<!--threads-->
<LI>Previous message: <A HREF="004445.html">[Mono-osx] How to pass nil?
</A></li>
<LI>Next message: <A HREF="004447.html">[Mono-osx] How to pass nil?
</A></li>
<LI> <B>Messages sorted by:</B>
<a href="date.html#4446">[ date ]</a>
<a href="thread.html#4446">[ thread ]</a>
<a href="subject.html#4446">[ subject ]</a>
<a href="author.html#4446">[ 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>