Unity3D for iOS: Storing a New High Score in Parse via UniParse while Adding a Value to a _ptr Field

So far this is the only way I’ve been able to successfully do this. I wonder if I’m missing something & there’s actually a better way to do this using only 1 call to Parse. Anyone? Feel free to prove me wrong. Please.

...
// localStorage is a PlayerPrefs instance that lets us grab values stored on the device that's running the app
...			 

// MyGameUsers is a Parse Class that stores unique user ID's as the parse Class' objectId's
// change MyGameUsers to your own Class name where appropriate.
var usersTablePointer = new ParseClass("/classes/MyGameUsers");

//"f2H4saD8" is an arbitrary value for demo purposes, a typical objectId from a Parse table  
string myQuery = "where={\"objectId\": \""+ "f2H4saD8" + "\" }";             				
			
ParseInstanceCollection prseList = gamerTablePointer.List(myQuery);		

//wait to get the Gamer object w/ our objectID specified in myQuery 
while(!prseList.isDone) yield return null;
			
ParseInstance[] items = prseList.items;		
				
// post a new record to the Score table in Parse:
// change MyGameScores to your own Class name where appropriate.
var myGameScoresClass = new ParseClass("/classes/MyGameScores");

//create a new record in the db table (represented by the ParseClass)
var myNewScore = myGameScoresClass.New();

//1034 is just an arbitrary score value; you can grab it from your own variable value			
myNewScore.Set( "Score", 1034 ); 	
myNewScore.Set( "MyGameUsers_ptr", items[0] as object );

//create the new record in the server side Parse Class (table) called "MyGameScores" (or your own class name)
myNewScore.Create();
				
//Wait until it's finished the save in Parse.
while(!myNewScore.isDone) yield return null;						

Debug.Log("myNewScore is done; check it in the MyGameScores table in the relevant Parse.com account.");		 

Unity3D for iOS: ParseInstance.GET(string) throws “InvalidCastException: Cannot cast from source type to destination type” for Date objects from Parse

The Error

//UniParse boiler plate:
var pObj = new ParseClass("/classes/Tournaments");			
string query = "...your query here..."; 	
ParseInstanceCollection MyParseList = pObj.List( query );			
while(!MyParseList.isDone) yield return null;					
ParseInstance[] items = MyParseList.items; 		

//get custom Date from a Parse.com Class (database table)
string MyDateFromParse = items[0].Get<string>("MyCustomDate"); 

The last line above throws this error because MyCustomDate is of type “date” in the Parse class:

/*
InvalidCastException: Cannot cast from source type to destination type.
ParseInstance.Get[String] (System.String key) (at Assets/Plugins/ParseClass.cs:238)
MyManager+<getMyCustomDateFromParse>c__Iterator15.MoveNext () (at Assets/Scripts/MyManager.cs:9)				
*/

The Solution

Read up on Data Types in Parse.com’s documentation.

Hashtable d = (Hashtable)items[0].Get<object>("MyCustomDate");
string MyDateFromParse = d["iso"];