i have 2 viewcontrollers, in first one, there 3 key-value pairs in each pfobject, save them parse after clicking button. in second viewcontroller, want create property , save same pfobject. here code:
in first viewcontroller:
- (void)next { pfobject *thisuser = [pfobject objectwithclassname:@"user"]; thisuser[@"name"] = [pfuser currentuser].username; thisuser[@"institution"] = institution.text; thisuser[@"major"] = major.text; [thisuser saveinbackgroundwithblock:^(bool succeeded, nserror *error) { if (succeeded) { guideviewcontroller2 *gvc2 = [[guideviewcontroller2 alloc]initwithnibname:@"guideviewcontroller2" bundle:nil]; uinavigationcontroller *nav = [[uinavigationcontroller alloc]initwithrootviewcontroller:gvc2]; nav.modalpresentationstyle = uimodalpresentationfullscreen; nav.modaltransitionstyle = uimodaltransitionstylefliphorizontal; [self presentviewcontroller:nav animated:yes completion:nil]; nslog(@"success"); } else { nslog(@"nope"); } }]; } and in second view controller, user can upload profile photo, want photo saved in same pfobject. there way retrieve object using [pfuser currentuser].username property? how user object under user class in order add photo key-value pair?
thx.
you can query user:
pfquery *query = [pfuser query]; [query wherekey:username_key equalto:username]; [query getfirstobjectinbackgroundwithblock:^(pfobject *object, nserror *error) { if (!error) { //you found user! pfuser *querieduser = (pfuser *)object; } }]; supposing username unique! username_key username field , username actual username.
Comments
Post a Comment