Javascript 新对象未出现在分析数据浏览器中

Javascript 新对象未出现在分析数据浏览器中,javascript,ios,objective-c,parse-platform,Javascript,Ios,Objective C,Parse Platform,我希望在用户注册我的iOS应用程序时创建一个新的userCategory对象。我认为最好的方法是在注册成功后调用Parse cloud代码函数来触发对象的创建。但是,当我检查Parse的databrowser时,会创建新用户,但不会创建与该用户关联的新userCategory 目标c代码: // Sent to the delegate when a PFUser is signed up. - (void)signUpViewController:(PFSignUpViewController

我希望在用户注册我的iOS应用程序时创建一个新的userCategory对象。我认为最好的方法是在注册成功后调用Parse cloud代码函数来触发对象的创建。但是,当我检查Parse的databrowser时,会创建新用户,但不会创建与该用户关联的新userCategory

目标c代码:

// Sent to the delegate when a PFUser is signed up.
- (void)signUpViewController:(PFSignUpViewController *)signUpController didSignUpUser:(PFUser *)user {
    [self dismissViewControllerAnimated:YES completion:NULL];

    [PFCloud callFunctionInBackground:@"userCategoryCreate"
                       withParameters:@{}
                                block:^(NSNumber *ratings, NSError *error) {
                                    if (!error) {
                                        //userCategory created
                                    }
                                }];
}
云代码:

Parse.Cloud.define("userCategoryCreate", function(request, response) {


  // Simple syntax to create a new subclass of Parse.Object.
var UserCategory = Parse.Object.extend("UserCategory");

// Create a new instance of that class.
var userCategory = new UserCategory();


  response.success("userCategory succesfully created!");
});

你应该做类似的事情:

// Simple syntax to create a new subclass of Parse.Object.
var UserCategory = Parse.Object.extend("UserCategory");

// Create a new instance of that class.
var userCategory = new UserCategory();

// set necessary fields for the new entry row ( if needed )
userCategory.set("categoryName","categoryFoo1");
...
..
.

// Then save the object

userCategory.save().then(function(savedObj){

 response.success("userCategory succesfully created!");

},function(saveError){

 response.error("Unable to create this object");

});

希望有帮助

我知道您在这里做什么,但是当我使用此代码时,我收到一个错误,说明错误:未调用success/error。知道为什么吗?对不起,我已经编辑了save,Parse.object的方法返回了一个Promise,所以我忘了调用Promise方法。如果您不想处理成功或错误,可以使用save.alwaysfunction{};