【问题标题】:Parse with Swift - If Contains Channel使用 Swift 解析 - 如果包含通道
【发布时间】:2015-09-07 17:47:50
【问题描述】:

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

这是我的代码:

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

我收到以下错误:

找不到接受所提供参数的“包含”的重载

对我做错了什么有任何想法吗?

【问题讨论】:

    标签: ios swift parse-platform


    【解决方案1】:

    您正在尝试将[AnyObject] 转换为String。试试这个(如果你使用的是 Swift 1.2):

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

    【讨论】:

      猜你喜欢
      • 2018-10-16
      • 1970-01-01
      • 2021-12-12
      • 1970-01-01
      • 1970-01-01
      • 2018-11-10
      • 1970-01-01
      • 1970-01-01
      • 2011-08-10
      相关资源
      最近更新 更多