Fabrizio Bartolomucci Fabrizio Bartolomucci - 6 months ago 27
iOS Question

Very funny error on Xcode 8.0 beta 3 in accessing function from notifications and timers

I am getting this very strange and rather mocking error from Xcode:
Funny Error Message
While executing:

NotificationCenter.default.addObserver(self, selector:#selector(Booking.loadElement(_:)), name:String(format:"portal%d", portalIdent), object:nil)


Timer(timeInterval:5, target:self, selector:#selector(Booking.bookingTimerMethod(_:)), userInfo:"load", repeats:false).fire()

As you see the compiler complaints the functions not to exist and suggest me to use the same functions!

What is this and how may I make up for it?


The reason was simply due to the fact I forgot to add parameter 'notification:'.

NotificationCenter.default.addObserver(self, selector:#selector(Booking.loadElement(notification:)), name:NSNotification.Name(rawValue: String(format:"portal%d", portalIdent!)), object:nil)

Works just fine.