Re: What's NSError **?
Re: What's NSError **?
- Subject: Re: What's NSError **?
- From: David Remahl <email@hidden>
- Date: Fri, 14 Nov 2003 07:07:55 +0100
On 13 nov 2003, at 20.24, Jason McInnes wrote:
OK, another fundamental question which I should know
the answer to, but...I'm new.
Anyway, the method declaration
+ (NSData *)sendSynchronousRequest:(NSURLRequest
*)request returningResponse:(NSURLResponse **)response
error:(NSError **)error
calls for an NSError ** and an NSURLResponse **...
Are these handles (pointers to pointers)? How do I
allocate those in Objective C?
I am assuming that when I call sendSynchronousRequest
I have to pass in allocated objects, rather than
unallocated handles. (I tried sending in unallocated
handles and got a bad access error.)
Since sendSynchronousReponse is supposed to set the
response and error by reference if necessary, how do I
construct the objects to pass in?
Jason
They're indeed pointers to pointers, but not handles (in the Mac
Toolbox sense). Typical usage would be this:
NSError *errorPtr;
NSURLResponse *responsePtr;
[receiverClass sendSyncronousRequest:request
returningResponse:&responsePtr error:&error];
When the method call returns, responsePtr will point to a response
object, and error will point to an error object (if one occured). They
are autoreleased.
I think you may optionally pass null instead of the response and the
error. Please consult the documentation for details.
In conclusion, the only thing the method expects, is a pointer to some
space where it can store a pointer to an object. You don't have to
initialize the pointers before passing them to the method.
/ Rgds, David Remahl
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.