objective c - NSTextField waits until the end of a loop to update -


here's problem: have code goes this

otherwincontroller = [[notificationwindowcontroller alloc] init]; (int = 0; < 10; i++) {     [otherwincontroller showmessage:[nsstring stringwithformat:@"%d", i]];     nslog(@"%d", i);     sleep(1); } 

where otherwincontroller subclass of nswindowcontroller using update window changes happen in code, , alloc init method opens nib , shows window. showmessage method changes nstextview display whatever text in parameter.

in nslog, text changes every second , counts ten. showmessage method, text blank full ten seconds , displays number 10. thoughts??

ftr, showmessage method

- (void)showmessage:(nsstring *)text { [[self message] setstringvalue:text]; } 

not should matter, that's pretty basic.

you can achieve desired effect right inside loop, if explicitly give run loop time run:

[[nsrunloop currentrunloop] rununtildate:[nsdate datewithtimeintervalsincenow: 0.1]]; 

Comments

Popular posts from this blog

objective c - Change font of selected text in UITextView -

php - Accessing POST data in Facebook cavas app -

c# - Getting control value when switching a view as part of a multiview -