我已经设置了一个创建字符串的云代码功能。因此,我希望通过Swift接收此字符串。
Cloud Code功能:
Parse.Cloud.define("customer", function(request, response){
stripe.customers.create({
email: request.params.useremail
}, function(err, customer) {
if(err){
console.log(err);
response.error(err);
}
else{
console.log(customer);
console.log(customer.id);
response.success(customer);
});
});
Swift Code
PFCloud.callFunctionInBackground("customer", withParameters: ["useremail": self.userEmailAdressTextField.text ?? ""], block: { (success: AnyObject?, error: NSError?) -> Void in
print("The result is \(success)")
print("The customer success ID is \(success?.objectForKey("id"))")
print("The customer ID is \(success?.objectForKey("customer.id"))")
})
Cloud Code功能正常工作,因为我能够创建客户并在Cloud Code日志中打印输出“customer.id”(字符串)。我已经尝试在Xcode中打印结果以查看会发生什么,但我引用的每个对象都标记为“nil”。