Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Generic Reference Type error Monotouch

I installed the latest version of Monotouch and I started seeing the following error when I try to deploy my build to the device.

Error MT4112: The registrar found an invalid type The generic type argument 'T' must have a reference type constraint in order to be exportable to ObjectiveC. (MT4112)

It looks like I need to add a where clause in the class here, but it doesn't seem to work in Monotouch.

public class NotificationObject<T> : NSObject
{
    public T Data { get; set; }
}
like image 312
Anup Marwadi Avatar asked Oct 04 '12 07:10

Anup Marwadi


1 Answers

This is a known issue in MonoTouch 6.0.2.

Note that creating generic subclasses of NSObject, or exporting generic classes to ObjectiveC, is not supported. It may work, or it may crash inexplicably and randomly.

We do plan to support at least some scenarios of exported generic classes in the future, but it is not on the immediate roadmap, so there is no timeline yet.

like image 190
Rolf Bjarne Kvinge Avatar answered Nov 01 '22 17:11

Rolf Bjarne Kvinge