Re: NSFileHandle / NSConcreteFileHandle problem
Re: NSFileHandle / NSConcreteFileHandle problem
- Subject: Re: NSFileHandle / NSConcreteFileHandle problem
- From: "Boaz Stuller" <email@hidden>
- Date: Sun, 30 Mar 2008 16:48:45 -0400
You have to pass a pointer to the object pointer not the object pointer
itself, i.e &fh not fh, when adding arguments to an invocation. So, the
correct call is:
[invocation setArgument:&fh atIndex:2];
Because objective-c objects' memory layout begin with a pointer to the
object's class, what actually occurred is that you set the argument to the
object's class rather than the object itself. That's why the error message
looks mostly correct, with only a subtle '+' instead of the '-' in front to
indicate it was interpreted as a class method.
Best wishes,
Bo
On Sun, Mar 30, 2008 at 3:30 PM, Jeff LaMarche <email@hidden>
wrote:
> I'm having an unusual problem with an NSFileHandle. I'm creating an
> NSFileHandle and initializing it with a file descriptor that's
> actually a network socket. I'm able to send and receive data using it
> and it works fine. Then, I pass the NSFileHandle instance as the first
> argument of an NSInvocation call
>
> [invocation setArgument:fh atIndex:2];
>
> When I invoke the invocation, it calls my method with the file handle
> as the first argument, exactly as it's supposed to, BUT, the file
> handle doesn't work. I get the following message in the console when
> my code tries to actually use it:
>
> *** +[NSConcreteFileHandle writeData:]: unrecognized selector sent to
> class 0xa014ba80
>
> The weird thing is, if I call:
>
> [invocation target] performSelector:[invocation selector]
> withObject:fh];
>
> it works just fine.
>
> Does anyone have any idea what might be going on here? I've tried
> creating a new NSFileHandle and initializing it with the descriptor
> taken from the first argument, and I get the same result doing that.
> I'm able to work around the problem, but I'd still like to know if I'm
> doing something wrong.
>
> TIA for any help anyone can offer.
> Jeff
> _______________________________________________
>
>
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden