简体   繁体   中英

How to see Print Debugging While Interface Builder Previews? IOS / XCode

When Interface Builder shows a preview of your ViewController, it must execute the code belonging to the views contained in that VC in order to draw them, right?

So... let's say you have some print debugging in your custom view...

print("draw() was executed")

... How can one see this output while Interace Builder is processing the preview?

Thanks!

As far as I have seen, there is no way of printing to the debug console when Interface Builder is executing your code. However, I did find it helpful to temporarily add messages to a label or textview instead.

If necessary, you can do conditional code that only execute when Interface Builder is running (or not) like below. That way, you can show a small message view that is only visible at design time, and otherwise hidden.

#if TARGET_INTERFACE_BUILDER
  // IB only
#endif

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM