phoboslab/Ejecta — pull request #146 by SRandazzo (2013-03-18 20:45:55+00:00)
Title: Add EJJavaScriptViewDelegate to EJJavaScriptView

Have been grappling with the best way to integrate Ejecta as part of a larger iOS app for a while now, and have found this solution works the best, would love your feedback on it.

Our JS app is creating a whole lot of "Binding" objects that our iOS app sometimes needs a reference to. For example: when creating an EJBindingKeyInput, we want access to that object so that our viewcontroller can manage some custom logic on it (set it's inputView and or inputAccessoryView). These are things that we don't want to be handled by the JS App it self. We also have some custom EJBinding-objects that are acting as "bridges" for more custom application specific behavior. The bridge typically provides a link between the JSView and the ViewController. Getting the correct reference to the "bridge" can be difficult however.

Another idea i've played with is using NSNotifications when our js app creates new objects. Like this we could inspect the notification.object's scriptView property to see if it matches the scriptview in our app. I prefer delegate pattern (although technically both could work side by side)