0
我有两个ViewControllers,在第一个中,每个PFObject有3个键值对,点击按钮后将它们保存为解析。在第二个ViewController中,我想创建另一个属性并将其保存到同一个PFObject。这里是我的代码:iOS-Parse如何检索给定用户名的对象?
第一的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");
}
}];
}
和我的第二个视图控制器,用户可以上传个人资料照片,我想这张照片被保存在同一个PFObject。那么有没有办法使用[PFUser currentUser].username
属性检索对象?如何在User类下获取此用户对象以添加照片键值对?
thx。
其实我设法做到这一点[PFQuery queryWithClassName:@“User”]。但感谢您的提示。 –
您是否使用自定义用户类?查询用户时,还应该使用'[PFUser query]'。 –