0

I Encrypted the images using AES algorithm. when I used this images in IKImageBrowserView it display images correctly but I can't able to drag and drop images to Pasteboard. I had set image representation to IKImageBrowserView Image Object like this

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

but its work when I give like this

- (NSString *)  imageRepresentationType
{
    return IKImageBrowserPathRepresentationType;
}

- (id)  imageRepresentation
{
    return path;
}

The above code is working because when I drag images from IKImageBrowserView it will return path of the image.

Now what I need to do for drag and drop Encrypted images in IKImageBrowserView to Pasteboard.

NewStack
  • 990
  • 8
  • 19

1 Answers1

0

Finally i got it.

For non file path represented images we need to implement -imageBrowser:writeItemsAtIndexes: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];
}
NewStack
  • 990
  • 8
  • 19