【发布时间】:2014-04-23 20:29:19
【问题描述】:
我希望在用户在我的 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!");
});
【问题讨论】:
标签: javascript ios objective-c parse-platform