从iOS应用程序调用云端function

我开发了云计算function来统计最后一天内的选票数量。

// Use Parse.Cloud.define to define as many cloud functions as you want. // For example: Parse.Cloud.define("confidenceRating", function(request, response) { // To define vars yesterday and today var today = new Date(); var yesterday = today.setDate(today.getDate() - 1); // "score" is the table's name var query = new Parse.Query("score"); // filter the query, 2 filters to be applied query.greaterThanOrEqualTo("createdAt", yesterday); query.lessThan("createdAt", today); // perfom the action query.find({ success: function(results) { var votes = results.length; response.success(votes); }, error: function() { response.error("something went wrong"); } }); }); 

我成功部署了代码。 但是如何开发SWIFT代码来调用函数呢? 在Parse.com上没有这个用途的Swift例子。 请帮帮我!

UPD。 1.我正在使用@rickerbhbuild议的代码

 PFCloud.callFunctionInBackground("confidenceRating", withParameters: nil) { results, error in if error != nil { // Your error handling here } else { // Deal with your results (votes in your case) here. } } 

但是我得到了错误

 2014-12-12 12:19:52.399 Rating[4082:166266] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '*** -[__NSPlaceholderDictionary initWithObjects:forKeys:count:]: attempt to insert nil object from objects[1]' *** First throw call stack: ( 0 CoreFoundation 0x012d3946 __exceptionPreprocess + 182 

以下是一些调用云代码函数的swift代码。

 let parameters = ["": ""] PFCloud.callFunctionInBackground("confidenceRating", withParameters: parameters) { results, error in if error != nil { // Your error handling here } else { // Deal with your results (votes in your case) here. } }