用Swift解析 - 如果包含Channel

时间:2015-09-07 17:47:50

标签: ios swift parse-platform

我正在使用Parse通过Swift进行推送通知。我正在尝试编写一个if语句,搜索当前订阅的频道并查看他们是否订阅了该特定频道。

这是我的代码:

let currentInstallation = PFInstallation.currentInstallation()
if(contains(currentInstallation.channels as String, "game1")) {
   // do something 
}

我收到以下错误:

  

无法找到接受所提供参数的“contains”的重载

我做错了什么想法?

1 个答案:

答案 0 :(得分:1)

您正在尝试将[AnyObject]投射到String。试试这个(如果你正在使用Swift 1.2):

let currentInstallation = PFInstallation.currentInstallation()
if (contains(currentInstallation.channels as! [String], "game1")) {
    // do something
}