如何使用PFCloud callFunction Xcode 7

时间:2015-09-18 17:24:48

标签: ios parse-platform cloud swift2 xcode7

let params = NSMutableDictionary()
params.setObject(fullName.text!.lowercaseString, forKey: "username")

let result: AnyObject? = PFCloud.callFunction("checkUsername", withParameters: params as [NSObject : AnyObject])

这适用于Xcode 6.3,但现在我更新到Swift 2(Xcode 7)它不再有效。我收到错误消息:

  

调用可以抛出,但没有标记为'try'并且未处理错误

我该如何解决这个问题?

另外,我不想使用PFCloud.callFunctionBackground

1 个答案:

答案 0 :(得分:1)

试试这个:

root /files/whatever/public;
index index.html;

location / {
    try_files $uri /index.html =404;
}

# Proxy requests to "/auth" and "/api" to the server.
location ~ ^/(auth|api) {
    proxy_pass http://application_upstream;
    proxy_redirect off;
}

在Swift 2.0中添加了try-catch语法,你可以阅读它here