iOS /解析服务器上的云功能,不起作用

问题描述 投票:0回答:1

我开始在iOS /解析服务器应用中使用云功能。

这是客户端应用程序上的快速代码:

PFCloud.callFunction(inBackground: "myCloudFunction",
                   withParameters: ["unitID": theObject.objectID,
                                    "userID": PFUser.current()!.objectId!]) {
    [weak self] (object: Any?, error: Error?) in
    if error != nil {
        if error?.localizedDescription == "NOTHING"
        {print("The given object has not been found. This should not happen.")}
        else {
            print("Error in \(#function)\n" + (error?.localizedDescription)!)
            print("object = \(String(describing: object))")
        }
        return
    }

    .........
}

问题是,此函数内部似乎有问题:

+ (NSMutableURLRequest *)urlRequestWithURL:(NSURL *)url
                                httpMethod:(NSString *)httpMethod
                               httpHeaders:(NSDictionary *)httpHeaders
                                parameters:(NSDictionary *)parameters {
                              .......
                                }

关于此说明:

    request.HTTPBody = [NSJSONSerialization
    dataWithJSONObject:parameters
               options:(NSJSONWritingOptions)0
                 error:&error];

我不知道问题是什么,但是我想我在代码中使用了某种错误的语法:

PFCloud.callFunction(inBackground: "myCloudFunction",
                   withParameters: ["unitID": theObject.objectID,
                                    "userID": PFUser.current()!.objectId!]) ...

任何相关提示将不胜感激。

ios parse-server nsjsonserialization heroku-api
1个回答
0
投票

您好,请通过以下链接,它可能会对您有所帮助https://docs.parseplatform.org/cloudcode/guide/

© www.soinside.com 2019 - 2024. All rights reserved.