I have a code in Swift 1.2 to create an array of dispatch_block_t and it works fine. But the same code throws error in Swift 2.0.
var menuView: btSimplePopUP!
let actions: [dispatch_block_t] = [{self.pickImages()},
{self.takePicture()},
{self.pickVideos()},
{self.shootVideo()},
{self.recordAudio()},
{self.closeView()}]
menuView = btSimplePopUP(itemImage: imgs as [AnyObject],
andTitles: titles as [AnyObject],
andActionArray: actions as NSArray as [AnyObject],
addToViewController: self)
The above code works fine in Swift 1.2. But in Swift 2.0, it throws the following error
[dispatch_block_t] is not convertible to NSArray
How can I create an NSArray with dispatch_block_t?
UPDATE:
I have replaced the above code with the following one,
let actions: [Any] = [{self.pickImages()},
{self.takePicture()},
{self.pickVideos()},
{self.shootVideo()},
{self.recordAudio()},
{self.closeView()}]
menuView = btSimplePopUP(itemImage: imgs as [AnyObject],
andTitles: titles as [AnyObject],
andActionArray: actions as! [AnyObject],
addToViewController: self)
Now, the previous error is gone. But I am getting the following error in run time,
fatal error: array element cannot be bridged to Objective-C
Any help will be appreciated.