Adobe Creative SDK 文件 Swift
Adobe Creative SDK Files Swift
我正在尝试重写下面 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);
}
...
Swift 转换
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)")
}
}
}
我正在尝试重写下面 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);
}
...
Swift 转换
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)")
}
}
}