我正试图用Swift重写下面的代码。然而在Swift中,itemSelections表示它必须是一种类型的[AnyObject]。有办法绕过这个吗?谢谢
Adobe代码

- (void)showFileChooser {

[[AdobeUXAssetBrowser sharedBrowser] popupFileBrowser:^(AdobeSelectionAssetArray *itemSelections) {
NSLog(@"Selected a file");
for(id item in itemSelections) {

AdobeAsset *it = ((AdobeSelectionAsset *)item).selectedItem;

NSLog(@"File name %@", it.name);
}
...

快速转换
AdobeUXAssetBrowser.sharedBrowser().popupFileBrowser({ (itemSelections:[AnyObject]!) -> Void in

最佳答案

这应该有效:

AdobeUXAssetBrowser.sharedBrowser().popupFileBrowser({ (itemSelections) in
    if let itemSelectionsAssets = itemSelections as? [AdobeSelectionAsset] {
        for itemSelectionAsset in itemSelectionsAssets {
            let item = itemSelectionAsset.selectedItem
            println("File name: \(item.name)")
        }
    }
}

关于xcode - Adobe Creative SDK文件Swift,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/28031665/

10-12 02:46