Re: newbie widgets/NSTimer question
Re: newbie widgets/NSTimer question
- Subject: Re: newbie widgets/NSTimer question
- From: Jonathan Turner <email@hidden>
- Date: Thu, 7 Feb 2002 09:29:38 -0500
>
JT> ...NSTextField sending messages to the NSTextView...
>
>
'course it is possible, but I don't see a sensible pattern with that.
>
Presume you did mean "textfield sends messages to my controller, which does
>
the proper action (of showing the text in textview and sending the command
>
to telnet)"?
Yes, I am trying to keep the MVC architecture like the tutorials taught. I
have the view classes for the TextField, TextView, and a specialized View of
my own. Then I have the Controller that handles the socket and one that
handles specific behind-the-scenes work for the specialized view. The idea
is to have the TextField send information to the SocketController and the
SocketController send that to the socket it owns, then whenever something
comes out of the socket, then the SocketController grabs it as text, adds it
to what has already been received(sadly I don't know of a way to append text
to a TextView so I don't have to refresh the view with an all new string and
scroll to the bottom) and informs the TextView of this new string and scrolls
the TextView to the bottom, so that what is new is displayed.
Eventually SocketController will also talk to the other specialized
controller that handles my specialized view (in this case it's a Chess
controller and a ChessView subclass of NSView)
>
JT> Second question, if I'm going in the right direction, how do I get my
>
JT> TelnetController object to send messages to NSTextView whenever there
>
is JT> new data on the socket?
>
>
I haven't tried myself and it is *known* that there are some bugs in the
>
underlying "select" implementation, but I would start with the NSFileHandle
>
-readInBackgroundAndNotify: feature.
Thanks! I'll try that out to see how far I can get.
>
subclass. If so, do refactor the code: NSTextView should remain a "dumb"
Indeed, thank you for making sure that was clear with me.
>
Generally, select is much better -- IF it works. It was reported many times
>
in the list that it alas does not with reading a file (so that "tail -f"
>
functionality can't be done so), I haven't tried with socket.
I noticed there is an undocumented NSSocket type class, but being that it is
undocumented I had no intention of using it. Has anyone had any luck using
this instead of the straight BSD style socket interface?
>
Its pretty straighforward, so far as I remember. Anyway, for this task I am
>
used to use another API (which is translated to NSTimers internally
>
anyway):
>
>
-(void)doThisEveryXXOfSecond {
>
...
>
[self performSelector:_cmd withObject:nil afterDelay:XX];
>
}
>
>
Just call it once, and it would repeat scheduling itself perpetually.
Does performSelector:withObject:afterDelay: come with an NSObject? Or do I
have to subclass something else to get to it? I'm assuming that this starts
performing the task and the code continues as usual before and after the _cmd
is called every XX seconds.
Jonathan
_______________________________________________
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.