Search code examples
swiftselectoribeaconios8.1

Swift iOS8.1 selector does not have a member named 'convertFromStringLiteral'


I used an iBeacon Library in Swift,

// Listening Notifications
func registerNotifications() {
    NSNotificationCenter.defaultCenter().addObserver(self, selector: Selector.convertFromStringLiteral("handleNotification:"), name: kBUOYDidFindBeaconNotification, object: nil)
}

After used the iOS8.1 SDK, the editor said:

'Selector.Type' does not have a member named 'convertFromStringLiteral'

How can I solve this problem? I tried the following code but not working.

 Selector("handleNotification:")

Solution

  • Just write the string without Selector:

    NSNotificationCenter.defaultCenter().addObserver(self, selector: "handleNotification:", name: kBUOYDidFindBeaconNotification, object: nil)