Hi all,
I was just wondering what is the best practice for coding with Storyboard. I have written quite a few different apps that use it and am quite comfortable with the basics, but I am sure that things could be better… At the moment I am doing 95% percent of the heavy lifting in the createscene event, I am sure this is not how things should be done so I was wondering how other people do things.
So far I have only written business apps, which generally have a lot of buttons, textfields, tableviews, scrollviews etc. At the moment I am putting all of these things in the createscene event because otherwise the screen is more or less blank (nothing populating the space) when it moves on the screen. Data quite often changes between scenes and I am required to “storyboard.purgeScene( lastScene )” on every scene to make sure the tableViews etc are recreated and represent these changes.
I also find that a lot of these objects interact with each other, and even more code ends up in the createScene event. For example I might have a button (in the createScene event) which creates a picker wheel which has no place being in the createScene event but ends up being there so that it has the correct scope. The only way I have found around this is to create a forward reference outside all the scenes, is this way I should approach this?
To make things slightly more complicated I am using OOP quite extensively (based on ArdentKid’s Guide to Object-Oriented Lua with Corona SDK) to create custom tiles or buttons for within the tableViews and scrollViews, I therefore have to make the sceneView global (or some other displayGroup) so that I can attach custom events to it. Is this global sceneView destroyed when the scene changes (wondering about memory management)?
I have also discovered that I am required to do a “package.loaded[“Classes.className”] = nil”) in the exitscene event to make sure the class is recreated and attached to the right instance of the global ‘sceneView’.
As I said at the beginning of this post - everything works at the moment, I am just looking for things I can improve on (especially since I am teaching Corona to my Y13 students).
Thanks for taking the time to read this, I would appreciate any suggestions/advice that anybody can give me as to how I can improve my structure.
Craig