Search code examples
iosobjective-ccocoaobjective-c-blocks

crash in NSFileCoordinator moving item to another url in Snow Leopard


I have used the NSFileCoordinator object to move a file from one location to another as under. I am executing this inside a block using dispatch_async API.

NSFileCoordinator* coordinator = [[NSFileCoordinator alloc] init];

NSString* srcPath = @"some path";
NSString* destPath = @"dest path";

NSURL* srcLocation = [NSURL urlWithPath:srcPath];
NSURL* destLocation = [NSURL urlWithPath:destPath];

[coordinator itemAtURL:srcLocation willMoveToURL:destLocation];

My deployment target is 10.7.

When I run the application in 10.9 there is no error and moves the file to destination location. But, if I run the same app in 10.7. It gives below exception as:

*** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[NSFileCoordinator itemAtURL:willMoveToURL:]: unrecognized selector sent to instance 0x7f7f921c3d70'

What could be the reason for this issue?


Solution

  • Because the method is available ins in OS X v10.8 and later.You can not use it in 10.7.