Search code examples
iosxamarin.iosnsurlrequestnsmutableurlrequest

How do do the equivalent of the objective-C mutableCopy in Monotouch?


I have some code in objective-C which uses the 'mutableCopy' method to make a mutable copy of an NSURLRequest object called 'request':

NSMutableURLRequest mutableRequest = [request mutableCopy];

How do I go about doing this in Monotouch?

I tried putting this code into an Objective-C monotouch binding dll but when I call the function which has this code in it, I get a hard crash in the simulator and the monodevelop ide unloads itself from memory spontaneously. The crash presumably has to do with trying to marshall the newly copied mutableRequest back to monotouch.

Any advice is greatly appreciated.


Solution

  • what about sending the selector for mutableCopy to the request object, this will send the IntPtr back to the Monotouch and then MonoTouch.ObjCRuntime.Runtime.GetNSObject from that IntPtr and casting it to NSUrlMutableURLRequest class (which is implemented in Monotouch)?