[Mono-osx] MonoMac: NSUrlConnection

Duane Wandless duane at wandless.net
Sat Jul 17 12:40:29 EDT 2010


Ok... the current handwritten method for SendSynchronousRequest does not
work.  I know it is not currently public but I wanted to figure out the
correct solution.

If you try to access the NSError object after, an exception is raised.
 Attached is a set of changes that will set the NSError object correctly.

You call it like this:
            NSURLResponse respUrl;
            NSError respErr = new NSError(NSObjectFlag.Empty);

            NSData data = NSUrlConnection.SendSynchronousRequest(m_urlReq,
out respUrl, respErr);

And the respErr.Handle is changed in the SendSync..Request method.  At least
for NSError you are required to pass the NSObjectFlag.Empty.

I think the binding should be the preferred solution.  So the attached diff
also changes the name of the selector so it does not clash with the binding.

And again the binding is:
[Static, Export ("sendSynchronousRequest:returningResponse:error:")]
NSData SendSynchronousRequest (NSUrlRequest request, out NSUrlResponse
response, out NSError error);

Thanks,
Duane


On Sat, Jul 17, 2010 at 12:12 PM, Miguel de Icaza <miguel at novell.com> wrote:

>
>> The ByRefPostProcessing change I already submitted for generator.cs works
>> for binding NSError** as out NSError.  However it has one side affect that
>> you cannot choose to ignore the parameter.  Which I believe was at least
>> part of the motivation for the handwritten method.
>>
>
> The motivation was to have a working binding and this code is shared with
> MonoTouch, so I want to keep it that way.
>
>
>> I have the beginnings of a modification to generator.cs to bind NSError**
>> as ref NSError, instead of out NSError.  With this you are required to pass
>> in an object, but if you pass null the parameter is ignored.
>>
>
> We are not going to support passing null for cases where we need an out or
> ref.
>
> Miguel
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.ximian.com/pipermail/mono-osx/attachments/20100717/a011c255/attachment.html 
-------------- next part --------------
A non-text attachment was scrubbed...
Name: nsurlconnection.changes
Type: application/octet-stream
Size: 1579 bytes
Desc: not available
Url : http://lists.ximian.com/pipermail/mono-osx/attachments/20100717/a011c255/attachment.obj 


More information about the Mono-osx mailing list