在 Xcode 界面生成器中打印日志样式
这确实不应该这么难,但我很难过。我只想做一些简单的事情,比如在我的应用程序中写出日志类型区域。问题是,如果我使用 NSTextField 那么消息会被覆盖,如果我使用 NSTextView 我尝试用“setEditable”锁定编辑功能,但这似乎锁定了应用程序。我收到太多消息,并且它没有像线程那样足够快地写出所有内容。
我想要重现的是用户可以看到的滚动日志,例如控制台和使用 NSLog。我应该使用什么?
感谢您的任何帮助。
This really shouldn't be this hard but I'm stumped. I just want to do something simple like write out a log type area in my app. Here is the problem, if I use NSTextField then the message gets overwritten, and if I use NSTextView I try and lock the edit feature with "setEditable" but this seems to lock up the app. I get too many messages and it doesn't write out everything fast enough as the threads.
Pretty much what I want to reproduce is a scrolling log which the user can see, like console and using NSLog. What should I be using?
Thanks for any help.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
写出文字就意味着有绘图代码。绘图成本很高,并且可能会占用您的主线程,因此您可能需要尝试专用一个线程/ns操作来附加输出字符串并将textView的textValue设置为输出字符串。这样,您现在运行的线程就不会与绘图代码绑定。
Writing text means there's drawing code. Drawing is expensive and can tie up your main thread, so you may want to try dedicating a thread/nsoperation to appending an outputString and setting a textView's textValue to the outputString. This way, the thread that you are now running on doesn't get tied up with the drawing code.