• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Problem with docs for NSWorkspaceRecycleOperation?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Problem with docs for NSWorkspaceRecycleOperation?


  • Subject: Problem with docs for NSWorkspaceRecycleOperation?
  • From: Greg Hurrell <email@hidden>
  • Date: Sun, 8 Jun 2003 18:28:58 +0930

Two questions about using NSWorkspace's performFileOperation:source:destination:files:tag: method with NSWorkspaceRecycleOperation. Here's some sample code:

NSWorkspace *ws = [NSWorkspace sharedWorkspace];
NSString *item = @"~/Desktop/test";
int err;

NSString *base = [item stringByExpandingTildeInPath];
NSString *directory = [base stringByDeletingLastPathComponent];
NSString *file = [base lastPathComponent];

if ([[NSFileManager defaultManager] fileExistsAtPath:base])
{
BOOL result = [ws performFileOperation:NSWorkspaceRecycleOperation
source:directory
destination:@""
files:[NSArray arrayWithObject:file]
tag:&err];

NSLog(@"Result is %d and err is %d", result, err);
}

1. Given the code above, it successfully moves the specified file to the trash, but it raises an exception:

-[NSFileManager fileSystemRepresentationWithPath:]: nil or empty path argument

If I change the destination argument from @"' to nil, the code executes without raising the exception. Why then, do the docs say?:

Some operations-such as moving, copying, and linking files-require a destination directory to be specified. If not, destination should be the empty string (@"").

And also, various examples of code using NSWorkspaceRecycleOperation that I've found on the web and in the archives all use the empty string (@""). Here's one such example:

http://cocoa.mamasam.com/MACOSXDEV/2001/11/2/17810.php

So does this mean the behaviour has changed since the docs were written? Should the docs be changed? Or is my code wrong?

2. Second question: There have been threads here about the NSWorkspaceRecycleOperation failing to successfully move items if there is already an item with the same name in the Trash. My testing shows this is not the case, but I've only tested on Mac OS X 10.2.6. Now, if a file called "test" is in the trash and you try to trash other files called "test" they'll be renamed "test copy", and "test copy 1", "test copy 2" etc.

When did this change? Can I count on the behaviour holding true for all versions of Mac OS X 10.2?

Thanks for your time and replies!

Cheers
Greg
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.

  • Prev by Date: Re: NSWindow resizing hack?
  • Next by Date: Print a number on the file icon.
  • Previous by thread: Re: NSWindow resizing hack?
  • Next by thread: Print a number on the file icon.
  • Index(es):
    • Date
    • Thread