Quantcast
Channel: Recent Threads — Xamarin Community Forums
Viewing all articles
Browse latest Browse all 204402

NSFormatter?

$
0
0

What is the correct way to implement NSFormatter in Xamarin.Mac? The reason why I ask this is because the MonoMac.Foundation.NSFormatter class has an incomplete API compared to the Objective-C implementation.

I need to implement the following methods:

  • -stringForObjectValue
  • -getObjectValue:forString:errorDescription
  • -isPartialStringValid:proposedSelectedRange:originalString:originalSelectedRange:errorDescription:

I tried implementing them in a subclass of MonoMac.Foundation.NSFormatter and [Export]ing them, but my application then crashed (with a NullReferenceException) sometime after my custom method returns, making it impossible to debug. (I have made sure that no null values have been returned, either directly or by reference, which makes this problem even more mysterious.)

Currently I am using an NSFormatter subclass written in Objective-C, in a dylib file that I have added to my project and referenced using the RequiredFrameworkAttribute. However, this is a sub-optimal solution, as the whole point of Xamarin.Mac is to be able to write Mac apps entirely in C#, with no Objective-C needed to make my app run (excluding any wrapped third-party libraries, of course).


Viewing all articles
Browse latest Browse all 204402

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>