I\'m trying to write an application for swift control iTunes. But when initializing the application returns an object of type AnyObject
, but must iTunesApplication.
An inelegant way to do work around the issue is to have iTunes
declared as an SBApplication
, then, when you call a function from iTunesApplication
, downcast iTunes
to an AnyObject
:
(iTunes as AnyObject).play()
Note that there is no type-safety if you do this: you could call any function declared in any Objective-C header: it's just not guaranteed to be implemented in a specific class, and thus will crash the program.