Help following Eddies Electronics Example

I’m trying to follow how things happen in Eddies Electronics (iOS). It may be best to point me directly to the appropriate documentation but a little plain language explanation will help. I’ve been working with Xojo (and previously Delphi) on the desktop and get the basics of OOP but I’m certainly no master of if. But I did write COBOL and CICS for about 30 years.

Here’s what I understand: CustomerView opens by default and connects to the DB which loads the recordset. When the users clicks on a customer from the CustomerView Table a new instance of a CustomerDetailView is created and the instance of Customer is set to the selected record.

Why do you create a new instance of CustomerDetailView - why not just use the base view?
In the DetailView, there is an instance of Customer defined as a property. Why do you pass another instance of Customer (as"c") to the DisplayCustomer method.
Why do you define a property as a public instance of customer and then define another instance of customer (mCustomer) as a private property.

I’m having a little trouble grasping the scope of instances of the class.

thanks for your patience…

I don’t know what you are asking here. What is “the base view”? A new CustomDetailView instance is created so that it can be displayed over the CustomerView.

It could certainly use the property instead of passing in the value to the method. But keep in mind, these are not separate instances; they refer to the same customer and are the same instance. Whether you want to use the property in each method or pass around references to it is just a design decision. Either way works.

Customer is a computed property. Setting its value sets the BackButtonTitle and displays the customer information, but it doesn’t retain any information itself. “mCustomer” is the backing property that contains the actual customer reference. Refer to the User Guide for more about computed properties.

Thanks Paul. Ok, I get the design decisions about properties.

But I still apparently don’t understand the difference in a View in iOS and a Window in desktop. Do I understand that by creating a new instance of the view you might have several different instances all active at the same time showing info from different customers?

What my end game is is a split screen on an iPad with the list of customers on the left and the details of the selected customer on the right.

By the way Paul, I have enjoyed you web seminars and also just finished watching your presentation on iOS at the Developer conference. Nice work.

Paul, I think what he is referring to this code under CustomerTable -> Action which reads

[code]Dim details As New CustomerDetailView

details.Customer = Customer(Me.RowData(section, row).Tag)

And if I am not wrong, he is asking why you would need to instantiate a new instance of CustomerDetailView as opposed to just calling Self.PushTo(CustomerDetailView).

From my understand, in the iOS apps, not all views are created implicitly when the application starts up. This is so because some of the views particularly those not on the Tabs may not be used so it is no point creating them in the background which will take up memory and memory is precious on a little device like the iPhone or the iPad.

Those views on the tabs are generated when the application starts as they form part of the current view.

If you open up a Desktop or a Web application, you will noticed that all views has this little control

Particularly the Implicit Instance. When this is on, the page is created when the application starts. Not an issue for a desktop with a lot of memory. However, the Implicit Instance option is not available for iOS applications because it is not a good idea to preload views.

In Eddie’s Electronics, there is probably only a few pages but imagine if it is a much bigger app with say 50 views then preloading all those 50 views at start up can slow down the app start up when users want them to be instance and be a drain on memory.

Since the CustomerDetailView view is not preload or pre-instantiated, you will need to do so yourself right before you need to pop the view out and thus the “New” comes in.

Incidentally about your question about the iPad Split Screen View, check out under the “Changing the Current View”.

As @Edwin Lau has explained so well, iOS does not use “Implicit Instantiation” for Views, so you cannot just refer to them by name like you can on Desktop and Web.

There are a couple examples of a Split Screen here:

  • Examples/iOS/Apps/XojoNotes
  • Examples/iOS/Navigation/SplitViewExample

The next Xojo release also has an updated iOS Eddies Electronics example that uses a SplitScreen when it runs on iPad.

Thank you guys. As you said, Edwin explained what I was asking…