• 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
fileManager:shouldMoveItemAtPath:toPath is never called
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

fileManager:shouldMoveItemAtPath:toPath is never called


  • Subject: fileManager:shouldMoveItemAtPath:toPath is never called
  • From: mpl <email@hidden>
  • Date: Mon, 20 Jul 2009 22:50:03 +0200

Hi,

I'm having a problem with moving files using moveItemAtPath:toPath:error from NSFileManager. The operation moves a file as it should, but associated delegate method is not called (fileManager:shouldMoveItemAtPath:toPath). If I switch from moving to copying (that is when I use copyItemAtPath:toPath:error instead of moveItemAtPath:toPath:error) the equivalent delegate works fine. I made a sample source code to show what the problem is - I'm including it below. When I compile it and run in XCode 3.1.3 (on OSX 10.5.7) it just prints "OK" and not "Test move" so that the delegate is not called. And the file is moved as it should be...

Have you seen this before?

Regards

#import <Foundation/Foundation.h>

@interface Test : NSObject {
}
- (BOOL)fileManager:(NSFileManager *)fileManager shouldMoveItemAtPath: (NSString *)srcPath toPath:(NSString *)dstPath;
@end


@implementation Test
- (BOOL)fileManager:(NSFileManager *)fileManager shouldMoveItemAtPath: (NSString *)srcPath toPath:(NSString *)dstPath {
NSLog(@"Test move");
return YES;
}
@end



int main (int argc, const char * argv[]) { NSAutoreleasePool * pool = [[NSAutoreleasePool alloc] init];

NSFileManager *fm = [NSFileManager defaultManager];
if ([fm createFileAtPath:@"./test.txt" contents:@"test" attributes:nil]) {

Test *t = [[Test alloc] init];
[fm setDelegate:t];

NSError *err;
if ([fm moveItemAtPath:@"./test.txt" toPath:@"./test1.txt" error:&err] == NO) {
NSLog(@"Error: %@", [err localizedDescription]);
} else {
NSLog(@"OK");
}
[t release];
} else {
NSLog(@"Cannot create a test file");
}

[pool drain];
return 0;
}
_______________________________________________


Cocoa-dev mailing list (email@hidden)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden


  • Prev by Date: [iPhone] CFAttributedStringRef autorelease - not possible?
  • Next by Date: CoreData could not fulfill a fault for...
  • Previous by thread: Re: [iPhone] CFAttributedStringRef autorelease - not possible?
  • Next by thread: CoreData could not fulfill a fault for...
  • Index(es):
    • Date
    • Thread