Re: Does movePath:toPath:handler correctly manage the handler return value?
Re: Does movePath:toPath:handler correctly manage the handler return value?
- Subject: Re: Does movePath:toPath:handler correctly manage the handler return value?
- From: Steve Weller <email@hidden>
- Date: Thu, 15 Feb 2007 20:48:00 -0800
For the archives I filed this as radar bug 5002223. A workaround is
to use an ivar as a flag.
On Feb 14, 2007, at 10:08 PM, Steve Weller wrote:
One thing I omitted that may be important: this is an Aperture plug-
in (version 2 API). The panel that appears is a PROAPI type of panel.
On Feb 14, 2007, at 9:16 PM, Steve Weller wrote:
movePath:toPath:handler appears to disregard the value returned by
the handler.
I am renaming a file like this (it's in a loop):
// Do the rename
NSLog(@"Will rename file at %@ to %@",frompath,topath);
if([manager movePath:frompath toPath:topath handler:self]==NO) {
NSLog(@"Rename failed");
[_exportManager shouldCancelExport];
return;
}
imageindex++;
And here is my handler:
// Handler for file rename operation
// Presents a dialog asking to continue or stop the operation
-(BOOL)fileManager:(NSFileManager *)manager
shouldProceedAfterError:(NSDictionary *)errorInfo
{
int result;
result = NSRunAlertPanel(@"Random Wok", @"An error (%@) has
occurred trying to rename an exported file to: %@", @"Continue",
@"Stop", NULL, [errorInfo objectForKey:@"Error"], _renamedFileName);
if (result == NSAlertDefaultReturn) {
NSLog(@"YES");
return YES;
} else {
NSLog(@"NO");
return NO;
}
}
I test this by creating a file that already exists, so making the
rename fail. The panel appears correctly and I can click the Stop
or Continue buttons. But "Rename Failed" always gets logged, and
so my method is always ended. I am logging the return value of -
fileManager:shouldPrroceedAfterError:errorInfo and it is correct.
I do get YES if I click Continue and NO if I click Stop.
The documentation says:
Return Value
YES if the move operation is successful. If the operation is not
successful, but the handler method
fileManager:shouldProceedAfterError: returns YES,
movePath:toPath:handler: also returns YES; otherwise returns NO.
But I am not getting that behavior.
I have implemented fileManager:WillProcessPath: as follows,
because the documentation requires that both methods be implemented:
- (void)fileManager:(NSFileManager *)manager willProcessPath:
(NSString *)path;
{
}
--
Bagelturf Blog http://homepage.mac.com/bagelturf/
_______________________________________________
Cocoa-dev mailing list (email@hidden)
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
--
Bagelturf Blog http://homepage.mac.com/bagelturf/
_______________________________________________
Cocoa-dev mailing list (email@hidden)
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
--
Bagelturf Blog http://homepage.mac.com/bagelturf/
_______________________________________________
Cocoa-dev mailing list (email@hidden)
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