Appending to NSTextView
问题 I've got an NSTask (with an NSPipe set up) running in the background and I want to output the contents, as they're coming in, in an NSTextView ( output ). The code I'm using is : NSMutableAttributedString* str = [[NSMutableAttributedString alloc] initWithString:s]; //[str addAttribute:NSForegroundColorAttributeName value:[NSColor whiteColor] range:NSMakeRange(0, [str length])]; [[output textStorage] appendAttributedString:str]; [output scrollRangeToVisible:NSMakeRange([[output string] length]