No visible @interface for 'NSFileManager' declares the selector 'moveItemAtPath:toPath:'

32 views Asked by At

I'm trying to use the moveItemAtPath method, but I am getting an error about using an interface.

> #import <Cocoa/Cocoa.h>
> 
> int main(int argc, const char * argv[]) {
>     @autoreleasepool { 
>         NSFileManager *manage = [NSFileManager defaultManager];
>         NSString *a = @"folder1/file.txt";
>         NSString *b = @"folder2/file.txt";
>         NSString *path = [NSHomeDirectory() stringByAppendingFormat:@"/%@", a];
>         NSString *newPath = [NSHomeDirectory() stringByAppendingFormat:@"/%@", b];
> 
>         [manage moveItemAtPath:path toPath:newPath];
>     }
>     return NSApplicationMain(argc, argv); }

I don't get how looking at the UIViewController , as explained in here https://stackoverflow.com/a/12696856 is supposed to help.

This resource does not show an example of what needs to be imported https://www.techotopia.com/index.php/Working_with_Files_in_Objective-C#Moving.2FRenaming_a_File

0

There are 0 answers