I’m trying to simplify my code and replace a bazillion occurrences of the same code with a global method. I get the error that’s the title of this thread on the two lines that reference ‘masterview’. What am I doing wrong?
Sub GoToView(masterview As iOSView)
If iOSSplitView.Available Then
Dim split As New iOSSplitView
Dim master As New masterview <---
split.Master = master
Dim detail As New FormView
split.Detail = detail
App.CurrentScreen.Content = split
Else
Dim nosplit As New masterview <---
App.CurrentScreen.Content = nosplit
End If
End Sub
You’re trying to create a new instance of a subclass with that New keyword.
If you want to use the instance of it that you passed to the method, you only need to reference the name.
So, split.Master = master becomes split.Master = masterview
Sub GoToView(masterview As iOSView)
If iOSSplitView.Available Then
Dim split As New iOSSplitView
split.Master = masterview
Dim detail As New FormView
split.Detail = detail
App.CurrentScreen.Content = split
Else
App.CurrentScreen.Content = masterview
End If
End Sub
[/quote]
You might be able to figure out what kind of view is being sent in to GoToView, but that just seems like it’s probably unnecessary for what you want to do. You can condense your call a little, but if you don’t dim it into a variable you won’t be able to use it elsewhere in the originating method.
GoToView(new ChoicesView)
This is all without looking at your project, so YMMV.