Question

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.

Was it helpful?

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)?

OTHER TIPS

Xamarin.iOS 7.0.6 now includes typed support for NSCopying and NSMutableCopying.

Types that conform to those protocols now export Copy(NSZone) or MutableCopy(NSZone) methods.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top