|
Preserving Patch StateSometimes, patches dynamically create input and output ports. Sometimes, they have instance-specific configuration. To preserve this kind of data across restarts of QC, we resort to saving our patches "state." This is how all the patches store their configuration so that they start up again in the same condition. By default, any patch that inherits from QCPatch gets basic port-value state saving. This saves the values provided to ports when you double-click them and enter text. But for complex state saving, like dynamic ports, Inspector panel values, and the like, we resort to using QCPatch's (Override) category methods, When implementing When QC starts up (or your patch gets loaded in some other QC-aware environment), setState is called with the returned NSDictionary. This method should set data appropriately, and return YES if it completes without any problems. Returning NO causes QC to pop up a warning dialog stating that one of the patches failed to restore. That's about all there is to it!
|