Get Object
Get a whole Object using a Query:
Java
Swift
1
import com.parse.ParseObject;
2
import com.parse.ParseQuery;
3
import com.parse.GetCallback;
4
import com.parse.ParseException;
5
6
public void getObject()
7
{
8
ParseQuery<ParseObject> query = ParseQuery.getQuery("ClassName");
9
query.getInBackground("objectId", new GetCallback<ParseObject>()
10
{
11
public void done(ParseObject object, ParseException e)
12
{
13
if (e == null)
14
{
15
// your object will be returned here
16
}
17
else
18
{
19
// something went wrong, check the exception for more infos
20
}
21
}
22
});
23
}
Copied!
1
import Parse
2
3
class testVC: UIViewController
4
{
5
override func viewDidLoad()
6
{
7
super.viewDidLoad()
8
self.getObjet(id:"AB1234")
9
}
10
11
12
func getObjet(id:String)
13
{
14
let query = PFQuery.init(className: "ClassName")
15
query.getObjectInBackground(withId: id)
16
}
17
}
Copied!
Get the values out of the Object:
Java
Swift
1
import com.parse.ParseObject;
2
3
public void getSomeValues(ParseObject object)
4
{
5
int age = object.getInt("age");
6
String userName = object.getString("userName");
7
boolean isFunny = object.getBoolean("isFunny");
8
ParseObject = object.getParseObject("customObject");
9
}
Copied!
Special values that have their own accessors:
Java
Swift
1
import com.parse.ParseObject;
2
3
public void getSpecialValues(ParseObject object)
4
{
5
String objectId = object.getObjectId();
6
Date updatedAt = object.getUpdatedAt();
7
Date createdAt = object.getCreatedAt();
8
ParseACL acl = object.getACL();
9
}
Copied!
1
Copied!
Refresh an object that you already have in memory with the latest data:
Java
Swift
1
import com.parse.ParseObject;
2
import com.parse.GetCallback;
3
import com.parse.ParseException;
4
5
public void refreshObject(ParseObject object)
6
{
7
object.fetchInBackground(new GetCallback<ParseObject>()
8
{
9
public void done(ParseObject object, ParseException e)
10
{
11
if (e == null)
12
{
13
// Success!
14
}
15
else
16
{
17
// Failure!
18
}
19
}
20
});
21
}
Copied!
Copy link