in Education by
I am running another processing thread, and I would like to log results to a NSTextView, that when a new line is posted, it updates the view and positions the scrollbar to the bottom. Any suggestions? - (void)runProc { do { [NSThread sleepForTimeInterval:0.1]; [self reportInfo:@"tick"]; } while (stop == NO); } - (void)report:(NSString*)string; { [[consoleView textStorage] beginEditing]; [[[consoleView textStorage] mutableString] appendString:string]; [[[consoleView textStorage] mutableString] appendString:@"\n"]; [[consoleView textStorage] endEditing]; NSRange range; range = NSMakeRange ([[consoleView string] length], 0); [consoleView scrollRangeToVisible: range]; } It gets to about 50 entries then locks the whole thing up. JavaScript questions and answers, JavaScript questions pdf, JavaScript question bank, JavaScript questions and answers pdf, mcq on JavaScript pdf, JavaScript questions and solutions, JavaScript mcq Test , Interview JavaScript questions, JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)

1 Answer

0 votes
by
Most of AppKit is not thread safe, you can't update an NSTextView from a secondary thread. All UI updates must be done on the main thread. You need to call your reporting method like this: [self performSelectorOnMainThread:@selector(report:) withObject:@"tick" waitUntilDone:YES];

Related questions

0 votes
    When I've registered an object foo to receive KVO notifications from another object bar (using addObserver:. ... Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Mar 24, 2022 in Education by JackTerrance
0 votes
    I am building an Android application with Cordova which is running inside a webview. I know I can access ... Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Apr 14, 2022 in Education by JackTerrance
0 votes
    How to download the Console log for a particular Jenkins build programmatically?...
asked Jul 17, 2021 in Technology by JackTerrance
0 votes
    I tried searching on google, and got literally no results when trying to figure out what this means. My ... Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Aug 1, 2022 in Education by JackTerrance
0 votes
    I have a simple submit method, where Console.log(11) is printed first then console.log(1). I need ... JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked May 22, 2022 in Education by JackTerrance
0 votes
    I have a simple submit method, where Console.log(11) is printed first then console.log(1). I need ... JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked May 19, 2022 in Education by JackTerrance
0 votes
    What will be the output of log (-5.8) when executed on R console? (a) NAN (b) NA (c) Error ... Functions and Debugging of R Programming Select the correct answer from above options...
asked Feb 15, 2022 in Education by JackTerrance
0 votes
    When I attempt to load data into BigQuery from Google Cloud Storage it asks for the Google Cloud Storage URI ... Developers Console? Select the correct answer from above options...
asked Feb 2, 2022 in Education by JackTerrance
0 votes
    It seems that from Google Cloud Console there is no way to delete a project. Select the correct answer from above options...
asked Feb 2, 2022 in Education by JackTerrance
0 votes
    If the function in a console is.matrix(X) returns true then X can be considered as a _______ (a) Matrix ... Debugging of R Programming Select the correct answer from above options...
asked Feb 13, 2022 in Education by JackTerrance
0 votes
    Which of these class is used to read characters and strings in Java from console? (a) BufferedReader (b) ... & Applets of Java Select the correct answer from above options...
asked Feb 24, 2022 in Education by JackTerrance
0 votes
    _______ will divert all subsequent output from the console to an external file. (a) sink (b) div (c) exp ... Started of R Programming Select the correct answer from above options...
asked Feb 15, 2022 in Education by JackTerrance
0 votes
    _____________ is the attack method for decoding user credentials. Using this technique an attacker can log on ... -Cyber Security:,Cyber Security-Jobs:,Cyber Security Applications...
asked Oct 31, 2021 in Education by JackTerrance
...