Attempt to insert non-property value Warning in Info
Could someone shed some light on this warning for me;
I am creating an empty array and then adding an object, in the case the current window, procs_window
and I get a warning as follows:
*** -[NSUserDefaults setObject:forKey:]: Attempt to insert non-property value '(
"[object TiUIWindow]"
)' of class '__NSArrayM'.
Code excerpt:
var procs_window = Titanium.UI.currentWindow;
var appwindows = [];
appwindows.push(procs_window);
Titanium.App.Properties.setList('appwindows', appwindows);
have also tried below with same warning:
var appwindows = [];
var procs_window = Titanium.UI.currentWindow;
appwindows[0] = procs_window;
Titanium.App.Properties.setList('appwindows', appwindows);
2 Answers
-
you are not going to be able to store the window objects in the Titanium.App.Properties.
My suggestion is that you just create a global variable that holds the window list.
Also properties are persisted across application sessions, is that what you really wanted to do with the window list?
-
here is one way to create a global window list
// myGlobal.js myGlobals = { windowList : new Array() };
then every js where you want to use the globals, just include the file and use it
Titanium.include('myGlobals.js'); var win1 = Titanium.UI.createWindow({ title : 'Tab 1', backgroundColor : '#fff' }); myGlobals.windowList.push(win1); Ti.API.info(myGlobals.windowList); Ti.API.info(myGlobals.windowList.length);