0
当前,当用户第一次打开我的Parse应用程序时,将在Parse数据库上创建一个新的Installation
对象,其中包含installationId
和其他属性。如何使Parse安装对象的属性成为用户对象的指针?
一旦登录,它更新此Installation
对象的userId
属性与objectId
串人的User
对象。它只不过是一个字符串,恰好相当于各自的对象Id,但我想要的是它也是指向那个User
对象的指针。
我试过将userId
属性设置为一个指针而不是来自网站的字符串,但是这给了我一个错误信息,说明Error: invalid type for key userId, expected object, but got string
,因为我的iOS代码以字符串形式发送它,而不是作为指向User
类的指针。
如何让我的代码中的userId字符串指向User
类?该文档是here,但我无法将其应用于此用例。
代码:
- (void)viewWillAppear:(BOOL)animated {
[super viewDidLoad];
if ([PFUser currentUser]) {
NSLog(@"User is logged in");
PFInstallation *currentInstallation = [PFInstallation currentInstallation];
NSString *userId = [PFUser currentUser].objectId;
//userId[@"parent"] = [PFUser currentUser];
[currentInstallation setObject:userId forKey: @"userId"];
[currentInstallation saveInBackground];
} else {
NSLog(@"User is not logged in");
//[welcomeLabel setText:@"Not logged in"];
}
}