mercredi 22 février 2017

SharedObject Not saving data safely?

I try to have an object with some immutable properties which initiate at the constructor and won't be able to change after initiation. Those properties then only have getter method. Since I want this object can be shared with other classes, I save it to the SharedObject class called saveIt().

All work fine when running the app on iOS (I do not test it on Android yet) except that if I completely shutdown the app from memory and reopen it, those properties' without setter are lost. The code is as below:

          var rooms:ArrayCollection = saveData.read("rooms") as ArrayCollection;
          if (!roomExists) {
                var room:Room;
                room = new Room(myID, myName, maxRoomSize);

                room.name = rm.name;
                room.timestamp = new Date();
                room.joinUrl = rm.joinUrl;
                room.attendeeUrl = rm.attendeeUrl;
                room.attendees = conferenceParameters.metadata.hasOwnProperty("attendees") ? conferenceParameters.metadata["attendees"] : null;

                rooms.addItem(room);
            }
            saveIt.save("rooms", rooms);

Aucun commentaire:

Enregistrer un commentaire