{"id":190919,"date":"2022-11-16T13:04:45","date_gmt":"2022-11-16T05:04:45","guid":{"rendered":"https:\/\/www.idc.net\/help\/190919\/"},"modified":"2022-11-16T13:04:45","modified_gmt":"2022-11-16T05:04:45","slug":"%e5%90%8e%e6%b5%aa%e4%ba%91ios%e6%95%99%e7%a8%8b%ef%bc%9aios%e6%96%87%e4%bb%b6%e5%a4%84%e7%90%86","status":"publish","type":"post","link":"https:\/\/idc.net\/help\/190919\/","title":{"rendered":"\u540e\u6d6a\u4e91IOS\u6559\u7a0b\uff1aiOS\u6587\u4ef6\u5904\u7406"},"content":{"rendered":"<h2>IOS\u6587\u4ef6\u5904\u7406<\/h2>\n<hr>\n<h3>\u7b80\u4ecb<\/h3>\n<p>\u6587\u4ef6\u5904\u7406\u4e0d\u80fd\u76f4\u89c2\u7684\u901a\u8fc7\u5e94\u7528\u7a0b\u5e8f\u6765\u89e3\u91ca\uff0c\u6211\u4eec\u53ef\u4ee5\u4ece\u4ee5\u4e0b\u5b9e\u4f8b\u6765\u4e86\u89e3IOS\u7684\u6587\u4ef6\u5904\u7406\u3002<\/p>\n<p>IOS\u4e2d\u5bf9\u6587\u4ef6\u7684\u64cd\u4f5c. \u56e0\u4e3a\u5e94\u7528\u662f\u5728\u6c99\u7bb1\uff08sandbox\uff09\u4e2d\u7684\uff0c\u5728\u6587\u4ef6\u8bfb\u5199\u6743\u9650\u4e0a\u53d7\u5230\u9650\u5236\uff0c\u53ea\u80fd\u5728\u51e0\u4e2a\u76ee\u5f55\u4e0b\u8bfb\u5199\u6587\u4ef6\u3002<\/p>\n<h3>\u6587\u4ef6\u5904\u7406\u4e2d\u4f7f\u7528\u7684\u65b9\u6cd5<\/h3>\n<p>\u4e0b\u9762\u5217\u51fa\u4e86\u7528\u4e8e\u8bbf\u95ee\u548c\u64cd\u4f5c\u6587\u4ef6\u7684\u65b9\u6cd5\u7684\u5217\u8868\u3002<\/p>\n<\/p>\n<p>\u4ee5\u4e0b\u5b9e\u4f8b\u4f60\u5fc5\u987b\u66ff\u6362FilePath1\u3001FilePath\u548cFilePath\u5b57\u7b26\u4e32\u4e3a\u5b8c\u6574\u7684\u6587\u4ef6\u8def\u5f84\uff0c\u4ee5\u83b7\u5f97\u6240\u9700\u7684\u64cd\u4f5c\u3002<\/p>\n<p>\u68c0\u67e5\u6587\u4ef6\u662f\u5426\u5b58\u5728<\/p>\n<pre>   NSFileManager *fileManager = [NSFileManager defaultManager];\n   \/\/Get documents directory\n   NSArray *directoryPaths = NSSearchPathForDirectoriesInDomains\n   (NSDocumentDirectory, NSUserDomainMask, YES);\n   NSString *documentsDirectoryPath = [directoryPaths objectAtIndex:0];\n   if ([fileManager fileExistsAtPath:@\"\"]==YES) {\n        NSLog(@\"File exists\");\n    }    \n<\/pre>\n<p>\u6bd4\u8f83\u4e24\u4e2a\u6587\u4ef6\u7684\u5185\u5bb9<\/p>\n<pre>   if ([fileManager contentsEqualAtPath:@\"FilePath1\" andPath:@\" FilePath2\"]) {\n      NSLog(@\"Same content\");\n   }\n<\/pre>\n<p>\u68c0\u67e5\u662f\u5426\u53ef\u5199\u3001\u53ef\u8bfb\u3001\u53ef\u6267\u884c\u6587\u4ef6<\/p>\n<pre>  if ([fileManager isWritableFileAtPath:@\"FilePath\"]) {\n      NSLog(@\"isWritable\");\n   }\n   if ([fileManager isReadableFileAtPath:@\"FilePath\"]) {\n      NSLog(@\"isReadable\");\n   }\n   if ( [fileManager isExecutableFileAtPath:@\"FilePath\"]){\n      NSLog(@\"is Executable\");\n   }\n<\/pre>\n<p>\u79fb\u52a8\u6587\u4ef6<\/p>\n<pre>   if([fileManager moveItemAtPath:@\"FilePath1\" \n   toPath:@\"FilePath2\" error:NULL]){\n      NSLog(@\"Moved successfully\");\n   }\n<\/pre>\n<p>\u590d\u5236\u6587\u4ef6<\/p>\n<pre>   if ([fileManager copyItemAtPath:@\"FilePath1\" \n   toPath:@\"FilePath2\"  error:NULL]) {\n      NSLog(@\"Copied successfully\");\n   }\n<\/pre>\n<p>\u5220\u9664\u6587\u4ef6<\/p>\n<pre> if ([fileManager removeItemAtPath:@\"FilePath\" error:NULL]) {\n      NSLog(@\"Removed successfully\");\n   }\n <\/pre>\n<p>\u8bfb\u53d6\u6587\u4ef6<\/p>\n<pre> NSData *data = [fileManager contentsAtPath:@\"Path\"];\n <\/pre>\n<p>\u5199\u5165\u6587\u4ef6<\/p>\n<pre>  [fileManager createFileAtPath:@\"\" contents:data attributes:nil];\n<\/pre>\n","protected":false},"excerpt":{"rendered":"<p>IOS\u6587\u4ef6\u5904\u7406 \u7b80\u4ecb \u6587\u4ef6\u5904\u7406\u4e0d\u80fd\u76f4\u89c2\u7684\u901a\u8fc7\u5e94\u7528\u7a0b\u5e8f\u6765\u89e3\u91ca\uff0c\u6211\u4eec\u53ef\u4ee5\u4ece\u4ee5\u4e0b\u5b9e\u4f8b\u6765\u4e86\u89e3IOS\u7684\u6587\u4ef6\u5904\u7406\u3002 IOS [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[189686],"tags":[],"class_list":["post-190919","post","type-post","status-publish","format-standard","hentry","category-ios"],"_links":{"self":[{"href":"https:\/\/idc.net\/help\/wp-json\/wp\/v2\/posts\/190919","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/idc.net\/help\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/idc.net\/help\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/idc.net\/help\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/idc.net\/help\/wp-json\/wp\/v2\/comments?post=190919"}],"version-history":[{"count":0,"href":"https:\/\/idc.net\/help\/wp-json\/wp\/v2\/posts\/190919\/revisions"}],"wp:attachment":[{"href":"https:\/\/idc.net\/help\/wp-json\/wp\/v2\/media?parent=190919"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/idc.net\/help\/wp-json\/wp\/v2\/categories?post=190919"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/idc.net\/help\/wp-json\/wp\/v2\/tags?post=190919"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}