Macos 拖放操作无法在IKImageBrowserView中工作

Macos 拖放操作无法在IKImageBrowserView中工作,macos,cocoa,ikimagebrowserview,Macos,Cocoa,Ikimagebrowserview,我用加密算法加密了这些图像。当我在IKImageBrowserView中使用此图像时,它可以正确显示图像,但我无法将图像拖放到粘贴板。 我已经将图像表示设置为像这样的IKImageBrowserViewimage对象 - (NSString *) imageRepresentationType { return IKImageBrowserNSDataRepresentationType; } - (id) imageRepresentation { return [[NSD

我用加密算法加密了这些图像。当我在
IKImageBrowserView
中使用此图像时,它可以正确显示图像,但我无法将图像拖放到粘贴板。 我已经将图像表示设置为像这样的
IKImageBrowserView
image对象

- (NSString *)  imageRepresentationType
{
    return IKImageBrowserNSDataRepresentationType;
}
- (id)  imageRepresentation
{
   return  [[NSData dataWithContentsOfFile:path]decryptWithString:PASS];
}
- (NSString *)  imageRepresentationType
{
    return IKImageBrowserPathRepresentationType;
}

- (id)  imageRepresentation
{
    return path;
}
但当我这样付出时,这就是工作

- (NSString *)  imageRepresentationType
{
    return IKImageBrowserNSDataRepresentationType;
}
- (id)  imageRepresentation
{
   return  [[NSData dataWithContentsOfFile:path]decryptWithString:PASS];
}
- (NSString *)  imageRepresentationType
{
    return IKImageBrowserPathRepresentationType;
}

- (id)  imageRepresentation
{
    return path;
}
上面的代码正在工作,因为当我从
IKImageBrowserView
拖动图像时,它将返回 图像的路径

现在我需要做的是将
IKImageBrowserView
中的加密图像拖放到粘贴板上。

最后我得到了它

对于非文件路径表示的图像,我们需要实现-
imageBrowser:writeItemSatiIndex:toPasteboard:

- (NSUInteger) imageBrowser:(IKImageBrowserView *) aBrowser writeItemsAtIndexes:(NSIndexSet *) itemIndexes toPasteboard: (NSPasteboard *)pasteboard
{
        NSUinteger index;

        //instantiate an array to store paths
        filesArray = [NSMutableArray array];

        //for each index...
for(index = [itemIndexes firstIndex]; index != NSNotFound; index = [itemIndexes indexGreaterThanIndex:index]){

                //...get the path you want to add to the pasteboard
                id myDatasourceItem = [_myDatasourceArray objectAtIndex:index];
                NSString *path = [myDatasourceItem myLargeImageFilePath];

                //add it to your array
                [filesArray addObject:path];
        }

        //declare the pasteboard will contain paths
[pasteboard declareTypes:[NSArray arrayWithObjects:NSFilenamesPboardType,nil] owner:self];

        //set the paths
[pasteboard setPropertyList:filesArray forType:NSFilenamesPboardType];

         //return the number of items added to the pasteboard
         return [filesArray count];
}