Re: What's NSError **? (RESOLVED)
Re: What's NSError **? (RESOLVED)
- Subject: Re: What's NSError **? (RESOLVED)
- From: Jason McInnes <email@hidden>
- Date: Thu, 13 Nov 2003 23:19:26 -0800 (PST)
Between Java and Objective-C, I haven't had to pass
something by reference in nearly 10 years...so long
ago I forgot how!
Thanks!
jason
--- David Remahl <email@hidden> wrote:
>
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
>
=====
Jason McInnes
2 Degrees
Cell: 206.849.3680
Email: email@hidden
__________________________________
Do you Yahoo!?
Protect your identity with Yahoo! Mail AddressGuard
http://antispam.yahoo.com/whatsnewfree
_______________________________________________
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.