I am writing an Objective-C application which communicates with a USB device. The application writes certain data to the device continuously and displays the status of the write operation in a textView, which is an object of NSTextView. I call the -[NSTextView insertText:]
method in the loop when I get the write operation status from the device.
The problem is that the NSTextView doesn't get updated at every call of -insertText:
. I get the entire contents of the NSTextView only after the entire loop has been executed.
I didn't see an appropriate refresh or update method for NSTextView class. How can I recieve the status of the operation and update the NSTextView simultaneously?
- (IBAction)notifyContentHasChanged:(NSInteger) block {
NSString *str;
str = [NSString stringWithFormat:@"Block Written Successfully: %d\n", block];
[data insertText:str];
}
- (IBAction)func {
while(USB_SUCCESS(status))
{
printf("\nBlocks Written Successfully: %d",BlockCnt);
[refToSelf notifyContentHasChanged:BlockCnt];
}
}
Note that the printf
on console is updated timely but not the NSTextView.