Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

xcode 6 beta 4 - MessageComposeResult is not convertible to OptionalNilComparisonType

Tags:

ios

swift

xcode6

I have just upgraded from Xcode 6 Beta 3 to Beta 4. In 3 my app was compiling perfectly however in 4 I have the following error. Can anyone explain and provide a solution please.

func messageComposeViewController(sendMsg: MFMessageComposeViewController, didFinishWithResult result: MessageComposeResult) {

    switch result {

    case MessageComposeResultSent :    //Error: MessageComposeResult is not convertible to _OptionalNilComparisonType
        label2.text = "Msg Sent"

    case MessageComposeResultCancelled : //Error: MessageComposeResult is not convertible to _OptionalNilComparisonType
        label2.text = "Msg Send Cancelled"

    case MessageComposeResultFailed :   //Error: MessageComposeResult is not convertible to _OptionalNilComparisonType
        label2.text = "Msg Send Failed"

    default:
        label2.text = "Msg Error"

    }

    self.dismissViewControllerAnimated(true, completion: nil)
    self.reloadInputViews()

}
like image 959
naughtynaj Avatar asked Aug 02 '14 20:08

naughtynaj


2 Answers

func messageComposeViewController(controller: MFMessageComposeViewController!, didFinishWithResult result: MessageComposeResult) {

    switch result.value {

    case MessageComposeResultSent.value :
        println("enviado")

    case MessageComposeResultCancelled.value :
        println("cancelado")

    case MessageComposeResultFailed.value :
        println("fallo")

    default:
        println("")

    }

}
like image 108
user3980732 Avatar answered Sep 24 '22 02:09

user3980732


It's a bug in the way this module is bridged to Swift. Report it. To use the module, stay in Objective-C until the Swift bridging bug is fixed.

The main part of the bug as it stands seems to me to be:

  • This should be an enum, and it isn't; it's a struct

  • The struct has a value, which ought to be capable of comparison, but it has no getter (you can set it on initialization but you can't get it later)

like image 27
matt Avatar answered Sep 25 '22 02:09

matt