As we already discussed earlier, there're other options creating a
Mirror. This is useful, for example, if you need to customize just how
much of your subject can be seen with a mirror. The
has additional initializers for this.
This is especially useful in two cases:
- If reflection is a core part of your code, so that you have more control
- If you write a library and you expect that consumers will use reflection on it and you'd rather surpress that.
The way you use it is via the
CustomReflectable protocol. This protocol only has one requirement:
var customMirror: Mirror. If you implement it, you can create your own
Mirror and return that instead of the custom