Views: created equally behaving differently

Apologies for repeating my question that I posed embedded in a discussion on 'changing view’s. I think I should have opened a new conversation with a new topic, so I do it herewith.

I create a new iOS project. I add a View that gets the name View 2. I add a httpsocket with code in the Pagereceived event.
That is all there is. So I have two identical views, View1 and View2. Both have a text-area (called ‘FromServerTA’) that I want the same information on that I get from in the PageReceived event of httpsocket.
The code in the PageReceived is simply

Dim buffer As Text = TextEncoding.UTF8.ConvertDataToText(Content)
View1(currentview).FromServerTA.text= buffer
View2(currentview).FromServerTA.text= buffer

This generates an error (during compilation) for the last line: Type View2,View2 has no member “FromServerTA.text”
No error for the identical line before where i would expect the same error for View1.

So I am still struggling with what the difference is between Views and Windows in the DT version.
One can refer to any object on any window from everywhere in DT XOJO.

I also tried to create instances of view and view;; so in the pageReceived event:
Var MyView1 as New View1
Var MyView2 as New View2
MyView1.FromServerTA.text= buffer
MyView2.FromServerTA.text= buffer

This gives no error(!) but the textareas are not filled with the buffer content

Please help me.

D i c k (sorry my name gets replaced by garbage when i use it as it is by the XOJO forum software, I hope by putting spaces between the chars the XOJO software is fooled)

Aside from the problem you are describing, I see another issue coming your way. In this code:

View1(currentview).FromServerTA.text= buffer View2(currentview).FromServerTA.text= buffer
You can’t just cast currentview to View1 or View2 without checking if they are of that type. You’ll get a TypeMismatchException or an IllegalCastException for one or the other.

If currentView IsA View1 then View1(currentview).FromServerTA.Text = buffer End If

As far as your described problem, it would be a lot easier to diagnose if you’d create a simple project that shows just the issue you are having.

Dear Greg,
thanks for your response.
Actually I tried to locate the ‘casting of Views’ in the iOS user guide for instance in the formal description of View, I couldn’t find this and I just stupidly copied it from the example of HTTPSocket in examples. Sorry.

What I describe is the whole test project.
The essential point has nothing to do with ‘current view’. It is that I have some information (text(‘buffer’) in this case). This information comes from somewhere (the internet in this case). I want the user be able to switch between 2 views of this information. For the sake of simplicity say a large font and a small font (of course this can be done with one view but just for this small test I use 2 views).
So View1 has a button that has code to switch to the other view (PushtTo) and a textarea (with for instance large font property) and the other Vew2 has a button switch from the second to the first view. And has also a textarea but here with tiny font.
Somewhere, for instance in the open event of the appear from the PageReceived event but not from within the View, I want to fill both text areas with the same text information. I think this is extremely basic. But I seem to have problems referring to the Viewsand their controls. I think my problems are caused by my background in DT-XOJO and treating Views in iOS as I treated Windows in DT-XOJO (and trying to convert a working DT-XOJO app into a iOS app).
Anyway in the simple example above the error occurs during compilation time and I think there should be no difference between View1 ad View2 at that poin (or aren’t they, does View1 have a special status?), They are identical in every aspect of the little project. So the error for View2, whatever error, should also occur for the View1. I really appreciate you getting me through these beginner’s issues. I initially submitted these questions to the Getting Started channel but I was sent to the target-ios one ;-(
D i c k

Sorry: Typon the sentence ‘Somewhere … , PageReceived event’ a ’ From somewhere, for instance from the app.Open event or from the PageReceived event,’

No need to apologize. It’s a somewhat advanced feature that new users often don’t get right.

Well you say that… but I can’t tell from your description how View2 is being created. My guess is that somewhere in your code, you’re doing something like :

Dim v as new View2 Self.pushTo v

If that’s the case, what you need to be doing is storing “v” in a global variable somewhere and then referencing that view as “v” instead of View2(currentView).

But again, without seeing your code, I’m just guessing.

Dear Greg,
OK I created the View2 as I suppose identical to how View1 appears. I dragged it form the library.
Can I attach this little project in some way to the conversation here so that you can inspect it?

BTW when dragging from the library the extra view gets automatically the name View2

Right, but unlike the desktop, until you create an “instance” of the view, it doesn’t exist in any form that allows you to do anything with it.

In terms of attaching a project, put the file on Dropbox or something and just paste the link into the forum.