ios - How to retrieve Parse object created by a User -


user i'm integrating parse in application , @ point have login function , running. i'm trying understand/learn how create , connect objects in class unique current logged in user , how retrieve objects.

so need figure out. found this question , it's same thing want achieve can't figure out "connection" speak, , if need add parameters user class and/or object class want retrieve from.

so simplicity let's have logged in user unique objectid has been created parse user class. when i'm logged in this:

pfobject *list = [pfobject objectwithclassname:@"lists"];     list[@"name"] = @"my list";      [list saveinbackgroundwithblock:^(bool succeeded, nserror *error) {         if (succeeded) {             // object has been saved.             nslog(@"success");         } else {             // there problem, check error.description             nslog(@"fail");         }     }]; 

the list created , stored in list class on parse account app. if let's log out , in again user created list, how retrieve unique list user?

in question (linked earlier) suggested , marked working:

pfquery *innerquery = [pfquery querywithclassname:@"user"]; [innerquery wherekey:@"usertype" equalto:@"x"];  // fix real user type  pfquery *query = [pfquery querywithclassname:@"post"]; [query wherekey:@"user" matchesquery:innerquery]; [query findobjectsinbackgroundwithblock:^(nsarray *posts, nserror *error) {      // posts posts post.user.usertype == x }]; 

in example, @"usertype", @"x" , @"user"? can explain hang of "flow" or connection between queries speak. can implement functionality i'm after.

before can make query parse , retrieve user information, have store some. done creating pfobject properties attached it. once saved, can retrieve information. here example create user object acts parent favorite objects.

pfobject *user = [pfobject objectwithclassname:@"user"]; [user saveeventually];  pfobject *favorite = [pfobject objectwithclassname:@"favorites"]; favorite[@"numberoffavorites"] = @(10); favorite.acl = [pfacl aclwithuser:[pfuser currentuser]]; favorite[@"parent"] = user;  [favorite saveeventually]; 

after saving can retrieve objects again given user:

pfquery *query = [pfquery querywithclassname:@"user"]; pfquery *innerquery = [pfquery querywithclassname:@"favorites"]; [innerquery wherekey:@"parent" matchesquery:query];  [[[innerquery findobjectsinbackground] continuewithblock:^id(bftask *task) {     if (task.error){         return nil;     }  }]; 

parse have good documentation , examples can along. hope helps. t


Comments

Popular posts from this blog

javascript - gulp-nodemon - nodejs restart after file change - Error: listen EADDRINUSE events.js:85 -

Fatal Python error: Py_Initialize: unable to load the file system codec. ImportError: No module named 'encodings' -

javascript - oscilloscope of speaker input stops rendering after a few seconds -