PFObject 错误没有名为 'Contains' 的成员(SWIFT Xcode Parse)

Error with PFObject does not have a member named 'Contains' (SWIFT Xcode Parse)

所以我正在尝试创建一个按邮政编码提供可用性的注册页面。例如,用户只能在其所在地区(邮政编码)提供该服务时才能注册。

这是我当前的代码,它检查用户在 TextField 中键入的内容,并与我的 Parse 数据库中的字符串进行比较,如果匹配;他们可以注册,新的 viewController 将会打开。

除了我只有 1 个错误。

class checkAvailability: UIViewController, UITextFieldDelegate {

@IBOutlet weak var zipCode: UITextField!
@IBAction func checkAvailBtn(sender: AnyObject) {
    checkZip()
}

func checkZip() {
    let usersZipCode = zipCode.text
    let query = PFQuery(className:"zipCodes")
    query.findObjectsInBackgroundWithBlock {
        (objects: [AnyObject]?, error: NSError?) -> Void in

        if error == nil {
            // The find succeeded.
            print("Successfully retrieved \(objects!.count) zip codes.")
            // Do something with the found objects
            if let zipCodes = objects as? [PFObject] {
                if zipCodes.contains({ [=13=]["zipCodes"] as! String == usersZipCode }) { **THIS IS THE LINE WITH THE ERROR**
                    println()("your in!") // transition to the new screen
                    performSegueWithIdentifier("beginSignUp", sender: self)
                }
                else {
                    println("your out.") // do whatever
                }
            }
        } else {
            // Log details of the failure
            print("Error: \(error!) \(error!.userInfo)")
        }
    }
}

错误是:

[PFObject] does not have a member named 'contains'.

感谢任何帮助。谢谢。

contains 方法仅在 Xcode 7 环境中的 Swift 2 中可用。您使用的是 Swift 1.2,那里没有 contains

解决方案:在 Xcode 7 beta

中编译您的代码