Blog Archives

How to copy a ParseObject to a new ParseObject in different class

There is no function to copy a ParseObject into another class. In order to do so, one will need to create a ParseObject of the new class and re-assign all the keyset into the new ParseObject.

ParseObject is kinda like a Map object, so it is easy to retrieve all available keys, just as what you will do with a map.

ParseObject sourceObject = sourceParseObject;
ParseObject targetObject = new ParseObject("NewClass");
for (Iterator it = sourceObject.keySet().iterator(); it.hasNext();) {
      Object key = it.next();
      targetObject.put(key.toString(),sourceObject.get(key.toString());
    }
Advertisements