Search code examples
ioscrashswiftnspredicatexcode6-beta6

Crash using NSPredicate in swift after Xcode Beta 6


My code worked good in Xcode beta 5 but after downloaded the beta 6, it crash.

This is the code I have :

extension String {

    /**
    * http://stackoverflow.com/questions/3139619/check-that-an-email-address-is-valid-on-ios
    */
    func isValidEmail() -> Bool {
        let emailRegex = ".+@([A-Za-z0-9-]+\\.)+[A-Za-z]{2}[A-Za-z]*";
        let emailTest = NSPredicate(format: "SELF MATCHES %@",emailRegex);
        return emailTest.evaluateWithObject(self);
    }
}

When executing, it crash at the NSPredicate line :

let emailTest = NSPredicate(format: "SELF MATCHES %@",emailRegex);

Someone know something about this problem ?


Solution

  • Try to delete derived data and then rebuild, this method fixed my problem !

    ~/Library/Developer/Xcode/DerivedData/