How to access the mobilescreen currently displayed as master in a split view

So I use mobilescreen.show to drill down a few levels.

Master             Detail
---------             --------
Screen1          Screen4
  Screen2          Screen4
    Screen3          Screen5

I make a selection on Screen5 and want to call a method in Screen3 to update the Screen3 display. But when I try to use

Screen3(Self.ParentSplitView.Master).Screen3Method

I get a crash because the splitview Master is still Screen1.

So my question is how do I access Screen3?

If you have iOSKit in your project, you could use the observer pattern.

The code in Screen5 would look like this:

JK_NotificationCenter.MainCenter.PostNotification("ANotificationName", self)


In Screen3.Opening event add this code:

JK_NotificationCenter.MainCenter.addObserver(self, WeakAddressOf NotificationReceived, "ANotificationName", nil)

Add this method to Screen3:

Protected Sub NotificationReceived(aNotification as JK_Notification)
  
  Select case aNotification.Name
    
  Case "ANotificationName"
    
    Screen3Method()

  End Select
  
End Sub

And finally in Screen3.Closing event:

//cleanup
JK_NotificationCenter.MainCenter.removeObserver(self)
3 Likes

One thing I will add - I HIGHLY suggest you make a Constants module and make all string names of notifications a constant so you don’t misspell the string somewhere and have it not work.