Is there a reason why you can't obtain a weak reference of an object inside the onUpdate function of a view?
class controller {
var test = "it works";
}
class TestView extends WatchUi.View {
var controller;
function initialize(controller) { // Passed in as a weak reference here
self.controller = controller;
var itWorksHere = controller.get()
System.println(itWorksHere.test); // print "it works"
}
function onUpdate(dc) {
// HERE
var con = controller.get();
System.println(con.test); // Causes the error below
}
}
Here is the crash I get
Error: Unexpected Type Error Details: Failed invoking <symbol> Stack: - onUpdate() at [Path] 0x100122bf Encountered an app crash