Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6147177
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T19:04:01+00:00 2026-05-23T19:04:01+00:00

I’ve created an app that has a NSTableView which represents a series of files.

  • 0

I’ve created an app that has a NSTableView which represents a series of files. From this, I want to be able to drag a row (i.e. a filename) from my NSTableView to Finder, and the file be created in that folder. However, the bit I can’t work out is that I need to modify the contents of the original file, before it gets copied to Finder.

I’ve added the following line so I can drag outside of my NSTableView:

[self.tableView setDraggingSourceOperationMask:NSDragOperationCopy forLocal:NO];    

And I can get it to copy the actual file, provided I add a current files location to the pasteboard, using:

- (BOOL)tableView:(NSTableView *)aTableView writeRowsWithIndexes:(NSIndexSet *)rowIndexes toPasteboard:(NSPasteboard *)pboard {
    [pboard declareTypes:[NSArray arrayWithObject:NSFilenamesPboardType] owner:nil];        
    NSMutableArray* dragfiles = [[NSMutableArray alloc] init];
    NSString* file = [self.files objectAtIndex:row];
    NSString* filepath = [[[self.pathControl URL] path] stringByAppendingPathComponent:file];
    [dragfiles addObject:filepath];
    [pboard setPropertyList:dragfiles forType: NSFilenamesPboardType];
    [dragfiles release];
} 

But, because I want to modify the contents of the file, I don’t want to put filepaths onto the pasteboard. I’ve tried using NSFileWrapper, but Finder doesnt seem to accept this as a valid format.

I’ve checked Google, and I’ve found several suggestions that you can create a temporary file and use that filepath. But, this feels ugly.

Is it possible to send data to Finder? Is there a way to solve this?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-23T19:04:02+00:00Added an answer on May 23, 2026 at 7:04 pm

    You will most likely want to use promise files, or NSFilesPromisePboardType rather than NSFilenamesPboardType. (Note: the promise file methods dragPromisedFilesOfTypes:fromRect:source:slideBack:event: and namesOfPromisedFilesDroppedAtDestination: that that documentation talks about are the generic NSView methods. NSTableView defines more convenient methods that you’ll use instead of the generic ones. That said, that should still provide info on how promise file drags work). NSTableView uses tableView:namesOfPromisedFilesDroppedAtDestination:forDraggedRowsWithIndexes:, which is where you can do the processing of your files. In your tableView:writeRowsWithIndexes:toPasteboard: method, you’ll declare NSFilesPromisePboardType, then set an array of filename extensions for the types of files you plan to write. The following is pseudo-code that outlines how you might approach it:

    - (BOOL)tableView:(NSTableView *)aTableView
         writeRowsWithIndexes:(NSIndexSet *)rowIndexes
            toPasteboard:(NSPasteboard *)pboard {
         [pboard declareTypes:[NSArray arrayWithObjects:NSFilesPromisePboardType, nil]];
    
         NSMutableArray *filenameExtensions = [NSMutableArray array];
         NSArray *draggedFilenames = [self.files objectsAtIndexes:rowIndexes];
         for (NSString *filename in draggedFilenames) {
              NSString *filenameExtension = [filename pathExtension];
              if (filenameExtension.length) {
                  [filenameExtensions addObject:filenameExtension];
              }
         }
         [pboard setPropertyList:filenameExtensions
                     forType:NSFilesPromisePboardType];
         return YES;
    }
    

    Then in your names-of-promisedFiles method:

    - (NSArray *)tableView:(NSTableView *)aTableView
           namesOfPromisedFilesDroppedAtDestination:(NSURL *)dropDestination
           forDraggedRowsWithIndexes:(NSIndexSet *)indexSet {
    
         NSArray *draggedFilenames = [self.files objectsAtIndexes:indexSet];
    
         for (NSString *filename in draggedFilenames) {
               // do your processing of files in here
              // if it may take a long time, you might need to do it on a background
              // thread
    
             NSString *fullPathToOriginal = nil;
              NSString *destPath =
             [[dropDestination path] stringByAppendingPathComponent:filename];
    
    
         }
         return draggedFilenames;
    }
    

    You should be able to calculate the original file path (not sure how you’re determining it, so I left it nil in the code above) and the destination file path (using something like in the code above).

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm parsing an RSS feed that has an ’ in it. SimpleXML turns this
That's pretty much it. I'm using Nokogiri to scrape a web page what has
I want to count how many characters a certain string has in PHP, but
For some reason, after submitting a string like this Jack’s Spindle from a text
I have a string like this: La Torre Eiffel paragonata all’Everest What PHP function
I've got a string that has curly quotes in it. I'd like to replace
I have a French site that I want to parse, but am running into
I have a text area in my form which accepts all possible characters from
I know there's a lot of other questions out there that deal with this
Does anyone know how can I replace this 2 symbol below from the string

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.