Parse.Com Querying User Class (Swift)

Swift Parse Query For Users That I Follow

What you have is ridiculously inefficient with the nested queries and table reloads... Once you get any sizable number of users, you're performing way too many queries and hitting that table refresh hard.

You want a table that just has all of the users your current user is following? Your Followers table should use pointers instead of object ids, then you can just use the includeKeys method on queries to have it fetch the following field of the Followers object, and find all objects where follower is equal to the current user.

With the IDs, you could get away with doing a matchesKeyInQuery method, with a Followers query where follower equals the current user's ID, and the User query has matchesKeyInQuery where the key is objectId, queryKey is following, and query is the Follower query. But pointers are the proper way to do join tables, not storing Ids.

You could also look into Relations, which may be a good fit for tracking users that you follow.

Swift & Parse: Query Results Where Column Class Is Equal To A Column In Users Class

let userQuery = PFUser.query();
// Set up user query
let issueQuery = PFQuery(className:"Issue");
issueQuery.whereKey("WorkGroup", matchesKey:"WorkGroup", inQuery:userQuery);

http://parseplatform.org/Parse-SDK-iOS-OSX/api/Classes/PFQuery.html#/c:objc(cs)PFQuery(im)whereKey:matchesKey:inQuery:

Swift 2 + Parse How to select all user into Users class

You should read in Parse documment
try code:

let query = PFQuery(className: "Users")
query.findObjectsInBackgroundWithBlock { (objs, error) -> Void in
// objs is array or dictionary
}

Parse.com Swift Multiple Class Query

There is.

PFQuery has a method called includeKey:, which allows you to add objects that will be returned with your query, in your case, you want to get the users and places related to the SavedPlace instances, right? So you do this:

let query = SavedPlace.query()
query.includeKey("place")
query.includeKey("user")
query.findObjects...

The result will be a list of SavedPlace objects with a pointer for user and place, where those objects have already been fetched, so all their fields (that aren't pointers) will be available to you.

You can even use dot notation with that method, so if you have a pointer in your Place class called Country and you want to fetch it as well, you can add query.includeKey("place.country") and it will be included in the query.

The best thing about this is that it will count as a single call.

Here's more information about includeKey

http://blog.parse.com/announcements/queries-for-relational-data/

Retrieve user's data with only the user's objectId - Parse & Swift

Since your user object is a pointer, when you run your query you need to tell Parse to include any extra information that's not part of that class. In this case, since it's a pointer, you need to do query.includeKey("user") or whatever the name of the column is that points to your user class.

Get the current user custom column data in Swift Parse

You can get any custom column using yourpfobject["yourcolumn"]..

In your case:

if let displayIntake = PFUser.currentUser()!["IntakeCode"] as? String {
txtIntake.text = displayIntake
}


Related Topics



Leave a reply



Submit