-
Notifications
You must be signed in to change notification settings - Fork 515
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[Fix] Add missing selectros for NSExpression.
Added the missing static factory methods and the missing property. In order to give a clean API a new flag was added to the NSExpression class to track if the Block property does return a block or a null ptr. The idea is to avoid user from seeing an obj-c exception. This commit fixes bug #35012: https://bugzilla.xamarin.com/show_bug.cgi?id=35012 The evaluation of the NSExpression and the defition of the NSExpressionHandler have also been fixed since both should be using NSObjects.
- Loading branch information
1 parent
ee07bcf
commit f98e34b
Showing
3 changed files
with
40 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
using System; | ||
using System.Runtime.InteropServices; | ||
|
||
namespace XamCore.Foundation { | ||
|
||
public partial class NSExpression { | ||
bool hasFunction = false; | ||
|
||
public static NSExpression FromFunction (NSExpressionHandler target, NSExpression[] parameters) | ||
{ | ||
// NSExpression is a class cluster. The only subclass that supports the Block property is the one | ||
// created by this static method. We set the flag so that the user does not get an obj-c exception | ||
// when using the property and instead get a null ptr is returned. | ||
var exp = _FromFunction (target, parameters); | ||
exp.hasFunction = true; | ||
return exp; | ||
} | ||
|
||
public NSExpressionHandler Block { | ||
get { | ||
if (hasFunction) | ||
return this._Block; | ||
return null; | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters