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
Post a Comment