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
How Constant Is the Firebase Anonymous Id
Swift 2 Protocol Extension Not Calling Overridden Method Correctly
Change Uibarbuttonitem from Uisearchbar
How to Install Xcode on an External Hard Drive Along with the iPhone Simulator.App
Is There a Writetofile Equivalent for Swift 3's 'Data' Type
In Swift, How to Have a Uiscrollview Subclass That Has an Internal and External Delegate
Swift/Uiview/Drawrect - How to Get Drawrect to Update When Required
How to Line Break Long Large Title in iOS 11
Add Switch in Uitableview Cell in Swift
In Swiftui, Where Are the Control Events, I.E. Scrollviewdidscroll to Detect the Bottom of List Data
Alamofire: Send JSON with Array of Dictionaries
Rxswift Merge Different Kind of Observables
Get an Array of Dates of the Current Week Starting on Monday
What Are 'Get' and 'Set' in Swift
Obj-C Cocoapods + Swift Framework