Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/security/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Objective c 解释如何在文件管理iOS中使用Trashitematrol方法_Objective C_Nsfilemanager - Fatal编程技术网

Objective c 解释如何在文件管理iOS中使用Trashitematrol方法

Objective c 解释如何在文件管理iOS中使用Trashitematrol方法,objective-c,nsfilemanager,Objective C,Nsfilemanager,我是苏尼尔。我正试图通过编程将文本文件移动到垃圾箱。这是密码 #import <Foundation/Foundation.h> int main(int argc, const char * argv[]) { @autoreleasepool { // - (BOOL)trashItemAtURL:(NSURL *)url resultingItemURL:(NSURL **)outResultingURL error:(NSError **)error NS_AV

我是苏尼尔。我正试图通过编程将文本文件移动到垃圾箱。这是密码

#import <Foundation/Foundation.h>
int main(int argc, const char * argv[])
{
@autoreleasepool {
//        - (BOOL)trashItemAtURL:(NSURL *)url resultingItemURL:(NSURL **)outResultingURL error:(NSError **)error NS_AVAILABLE_MAC(10_8);

NSFileManager * aFM = [NSFileManager defaultManager];
NSURL * trash;
NSError * error;

NSURL * url = [NSURL URLWithString:@"/Users/SunilKumar/Desktop/samResTemp/samResources.text"];

NSLog(@"trashItemAtURL %hhd",[aFM trashItemAtURL:url resultingItemURL:&trash error:&error]);

}
return 0;
}
#导入
int main(int argc,const char*argv[]
{
@自动释放池{
//-(BOOL)trashitematural:(NSURL*)url resultingItemURL:(NSURL**)outResultingURL错误:(NSError**)错误NS\u可用\u MAC(10\u 8);
NSFileManager*aFM=[NSFileManager defaultManager];
NSURL*垃圾;
n错误*错误;
NSURL*url=[NSURL URLWithString:@”/Users/SunilKumar/Desktop/samResTemp/samResources.text];
NSLog(@“Trashitematrol%hhd”,[aFM Trashitematrol:url resultingItemURL:&垃圾箱错误:&错误];
}
返回0;
}
但我得到的输出是“Trashitematural 0”


请帮我做这件事。提前感谢您提供文件系统中的URL(scheme
文件://
),您必须使用
fileURLWithPath:
初始值设定项

NSURL * url = [NSURL fileURLWithPath:@"/Users/SunilKumar/Desktop/samResTemp/samResources.text"];
URLWithString
初始值设定项用于具有不同方案的URL,如
http://
ftp://

但是,要使用带有文件路径的
URLWithString
初始值设定项,必须在字符串中包含该方案

NSURL * url = [NSURL URLWithString:@"file:///Users/SunilKumar/Desktop/samResTemp/samResources.text"];