【问题标题】:Gaining information using CurrentUser - Parse使用 CurrentUser - Parse 获取信息
【发布时间】:2014-07-18 02:22:37
【问题描述】:

所以我使用 parse 和 User 类让用户注册和登录。我正在尝试使用 currentUser 方法来确定是否有人已经登录,然后像这样“跳过”登录过程。

 if ([PFUser currentUser]) {
    [self performSegueWithIdentifier:@"welcome" sender:self];
 }

然而,欢迎转场还需要将人的用户名发送到下一个视图控制器。当用户自然登录时,它会执行此操作。

-(void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender{
    if([segue.identifier isEqualToString:@"welcome"]){
        SheffPushHomeViewController *vc = segue.destinationViewController;
        vc.userID = self.username.text;

    }
}

所以我想知道是否可以使用 currentUser 方法从解析中获取用户名?这是我迄今为止实施的完整方法。任何帮助都会很棒!

  if ([PFUser currentUser]) {
    [self performSegueWithIdentifier:@"welcome" sender:self];
    PFQuery *query = [PFQuery queryWithClassName:@"User"];
    [query getObjectInBackgroundWithId:currentUser block:^(PFObject *currentUser, NSError *error) {
        NSString *playerName = currentUser[@"username"];

    }];

}

【问题讨论】:

    标签: ios objective-c parse-platform


    【解决方案1】:

    你可以直接从[PFUser currentUser]获取这个值:

    NSString *playerName = [PFUser currentUser][@"username"];

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2020-09-27
      • 1970-01-01
      • 2017-10-04
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2016-01-09
      相关资源
      最近更新 更多