I have custom IBDesignable
classes in swift that do some things that cause crashes in Interface Builder. Is there a flag I can check to see if I'm running in interface builder or not? Ideally it would be a precompiler directive (#ifdef COMPILED_FOR_INTERFACE_BUILDER
or something like that). I thought maybe I could set a flag myself in prepareForInterfaceBuilder()
but that seems messy and doesn't seem to work reliably as it looks class properties are set before that function is called and this can trigger code that causes problems. Seems like there must be a better way.
Thanks!
Checking if code is running in Interface Builder
2.5k views Asked by Michael John Ilardi At
1
From https://developer.apple.com/library/ios/recipes/xcode_help-IB_objects_media/Chapters/CreatingaLiveViewofaCustomObject.html: