javascript - 新对象未出现在解析数据浏览器中

标签 javascript ios objective-c parse-platform

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

objective-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");

});

希望对你有帮助

关于javascript - 新对象未出现在解析数据浏览器中,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23254568/

相关文章:

objective-c - Objective C - 覆盖 setter 以接受不同类型的对象

javascript - 无法读取未定义的属性 'querySelectorAll'

c# - 回调后重新加载插件

javascript - Tesseract.js 在控制台中挂起

ios - 当单元格离开屏幕时,Tableview 单元格内容会更改

ios - 如何通过一个按钮链接两个 iphone 应用程序

objective-c - 在 Cocoa 中使用 NSTimer 关闭自定义 NSPanel

javascript - 新用户的 Firebase 数据库安全

ios - 如何使用自动化生成随机 iOS 用户事件?

objective-c - 如何填充数组并同时查看其数据 - Swift - IOS9