Re: user-stoppable program
Re: user-stoppable program
- Subject: Re: user-stoppable program
- From: email@hidden
- Date: Thu, 25 May 2006 16:25:07 +0200 (CEST)
- Importance: Normal
> For instance, you say the "Stop It" button is disabled.
> Have you disabled it in your code or in Interface Builder?
I do not disable the "Stop it" button in my code or elsewhere ; indeed,
I do not need it disabled at any time. It's just that the whole window
(including the "Stop It" button) freezes itself automatically when the
main loop is running, because it's busy.
>
> I see that you have an -updateUI method ... could you be disabling
> (as opposed to *enabling*) the button when this method is called? Do
> you have the button connected to an outlet so you can say something
> like [stopItButton setEnabled:YES]?
Yes I have an outlet connection exactly as you say, but your suggestion
does not solve the problem. As someone else pointed out, the class NSThread
is the correct tool to deal with this :
>Sounds like you might need to use multithreading here. Take a look
>at the docs for NSThread, specifically the class method
>detachNewThreadSelector: toTarget: withObject:
Indeed, according to the documentation, ``you can use threads to
perform several, lengthy calculations while your user interface
continues to respond to user commands" : this is exactly
what I'm looking for (I want my application to perform the calculations
and at the same time
have a responsive UI)
I'm working on it, but as I'm not familiar with threads any further
help from those who use NSThread every day would be welcome !
Ewan
>
> On May 25, 2006, at 4:20 AM, email@hidden wrote:
>
>> Hello all,
>>
>> in a document-based Cocoa project the window has several table
>> views and
>> two buttons
>> ``Launch" and ``Stop It", corresponding to the following methods in
>> MyDocument.m :
>>
>>
>> -(IBAction) goOnAndOn : (id) sender
>> {
>> while (watchDog) {
>> [self goForward];
>> [self updateUI];
>> }
>> }
>>
>> -(IBAction) stopItAll : (id) sender
>> {
>> watchDog=NO;
>> }
>>
>> This does not work at all, because the Button ``Stop It" is
>> disabled when
>> the program is
>> busy. What is the proper way to do this ? Should I use delegates ? In
>> which class ?
>>
>>
>> Ewan
>>
>>
>>
>> _______________________________________________
>> Do not post admin requests to the list. They will be ignored.
>> Cocoa-dev mailing list (email@hidden)
>> Help/Unsubscribe/Update your Subscription:
>> 40gmail.com
>>
>> This email sent to email@hidden
>
>
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden