{"id":6922,"date":"2025-11-22T15:36:17","date_gmt":"2025-11-22T07:36:17","guid":{"rendered":"https:\/\/t.n-years.com\/?p=6922"},"modified":"2025-11-22T15:36:17","modified_gmt":"2025-11-22T07:36:17","slug":"icloud-document-%e8%a7%a3%e5%8e%8b%e7%9b%ae%e5%bd%95%e5%8f%8a%e6%96%87%e4%bb%b6%e5%a4%84%e7%90%86","status":"publish","type":"post","link":"https:\/\/t.n-years.com\/?p=6922","title":{"rendered":"iCloud Document \u89e3\u538b\u76ee\u5f55\u53ca\u6587\u4ef6\u5904\u7406"},"content":{"rendered":"<p>\u5982\u679c\u4f60\u7684 App <strong>\u4e0d\u652f\u6301\u76ee\u5f55\u7ea7\u540c\u6b65<\/strong>\uff08iCloud \u4e0d\u5efa\u8bae\u76f4\u63a5\u642c\u6574\u4e2a\u76ee\u5f55\uff09\uff0c\u4f46\u7528\u6237\u53c8\u89e3\u538b\u51fa\u4e00\u4e2a\u5305\u542b <strong>\u5927\u91cf\u6587\u4ef6\uff08\u51e0\u767e\uff5e\u51e0\u5343\uff09<\/strong> \u7684\u76ee\u5f55\uff0c\u4f60\u9700\u8981\u89e3\u51b3\uff1a<\/p>\n<ol>\n<li><strong>iCloud Document \u76ee\u5f55\u4e0d\u80fd\u76f4\u63a5 move \u6574\u4e2a\u76ee\u5f55<\/strong><\/li>\n<li><strong>\u6587\u4ef6\u6570\u91cf\u592a\u5927\uff0c\u9010\u4e2a copy \u6027\u80fd\u5dee\u3001\u963b\u585e\u4e3b\u7ebf\u7a0b<\/strong><\/li>\n<li><strong>iCloud \u6709\u6587\u4ef6\u6570\u9650\u5236\uff08\u9690\u6027\uff0c\u4f46\u5f71\u54cd\u6027\u80fd\uff09<\/strong><\/li>\n<li><strong>\u540c\u6b65\u4f1a\u5f88\u6162\u6216\u5bfc\u81f4 NSMetadataQuery \u5361\u6b7b<\/strong><\/li>\n<\/ol>\n<p>\u4e0b\u9762\u7ed9\u4f60\u4e00\u4e2a\u300c\u5927\u6587\u4ef6\u5939\u8fc1\u79fb\u5230 iCloud\u300d\u7684<strong>\u6700\u4f73\u5b9e\u8df5\u65b9\u6848<\/strong>\uff0c\u662f\u6587\u4ef6\u7ba1\u7406\u7c7b App\uff08\u5982 Documents\u3001FileBrowser\uff09\u5b9e\u9645\u4f7f\u7528\u7684\u6a21\u5f0f\u3002<\/p>\n<hr \/>\n<h1>\u2705 \u603b\u4f53\u7b56\u7565\uff1a\u4e24\u5c42\u903b\u8f91<\/h1>\n<h3><strong>1. \u672c\u5730\u89e3\u538b\u540e\u7684\u76ee\u5f55\u4fdd\u6301\u5728\u6c99\u76d2\uff0c\u4e0d\u76f4\u63a5\u8fc1\u79fb\u6574\u4e2a\u76ee\u5f55<\/strong><\/h3>\n<ul>\n<li>iCloud \u4e0d\u9002\u5408\u540c\u6b65\u300c\u5927\u91cf\u5c0f\u6587\u4ef6\u300d<\/li>\n<li>\u7528\u6237\u672a\u5fc5\u9700\u8981\u5168\u90e8\u6587\u4ef6\u4e0a\u4f20\u5230\u4e91\u7aef<\/li>\n<\/ul>\n<h3><strong>2. \u53ea\u6309\u9700\u4e0a\u4f20\u7528\u6237\u9009\u62e9\u7684\u6587\u4ef6\uff0c\u4e0d\u662f\u6574\u4e2a\u76ee\u5f55\u7ed3\u6784<\/strong><\/h3>\n<ul>\n<li>\u6587\u4ef6\u7ba1\u7406\u7c7b App \u7684\u901a\u7528\u505a\u6cd5<\/li>\n<li>\u51cf\u5c11 iCloud \u540c\u6b65\u6210\u672c<\/li>\n<li>\u907f\u514d\u79fb\u52a8\u4e0a\u5343\u4e2a\u6587\u4ef6\u5bfc\u81f4 UI \u5361\u987f\u548c\u8bbe\u5907\u8d44\u6e90\u7206\u70b8<\/li>\n<\/ul>\n<hr \/>\n<h1>\ud83c\udfaf \u4e09\u79cd\u53ef\u884c\u5904\u7406\u65b9\u5f0f\uff08\u6309\u6700\u4f73\u2192\u4e00\u822c\u6392\u5e8f\uff09<\/h1>\n<hr \/>\n<h1>\u2b50 \u65b9\u6848 1\uff1a<strong>\u6253\u5305 \u2192 \u4e0a\u4f20\u4e00\u4e2a\u6587\u4ef6\uff08\u5f3a\u70c8\u63a8\u8350\uff09<\/strong><\/h1>\n<blockquote>\n<p>\u5f53\u89e3\u538b\u540e\u4ea7\u751f\u5927\u91cf\u6587\u4ef6\u65f6\uff0c\u628a\u6574\u4e2a\u76ee\u5f55\u91cd\u65b0\u538b\u7f29\u6210\u4e00\u4e2a <code>.zip<\/code>\uff0c\u53ea\u4e0a\u4f20\u8fd9\u4e2a\u538b\u7f29\u5305\u3002<\/p>\n<\/blockquote>\n<p>\u4f18\u70b9\uff1a<\/p>\n<ul>\n<li>iCloud \u53ea\u4e0a\u4f20\u4e00\u4e2a\u6587\u4ef6\uff0c\u540c\u6b65\u5feb\u3001\u7a33\u5b9a<\/li>\n<li>\u907f\u514d\u4e0a\u767e\uff0f\u4e0a\u5343\u4e2a\u6587\u4ef6\u5bfc\u81f4 iCloud \u5361\u6b7b\u6216\u62d2\u7edd\u540c\u6b65<\/li>\n<li>\u4e0b\u8f7d\u6062\u590d\u65f6\u518d\u89e3\u538b\u5373\u53ef<\/li>\n<\/ul>\n<p>\u5178\u578b\u6d41\u7a0b\uff1a<\/p>\n<pre><code class=\"language-swift\">\/\/ \u4f2a\u4ee3\u7801\nlet zipURL = createZip(fromFolder: extractedFolderURL)\nmoveToICloud(zipURL)<\/code><\/pre>\n<p>Documents \/ PDF Expert \u5c31\u662f\u8fd9\u6837\u5904\u7406\u7684\u3002<\/p>\n<hr \/>\n<h1>\u2b50 \u65b9\u6848 2\uff1a<strong>\u589e\u91cf\u4e0a\u4f20\uff08\u7528\u6237\u9009\u62e9\u54ea\u4e9b\u6587\u4ef6\/\u5939\u4e0a\u4f20\uff09<\/strong><\/h1>\n<p>\u4e0d\u8981\u5168\u91cf\u4e0a\u4f20\uff0c\u6539\u4e3a\uff1a<\/p>\n<p>\ud83d\udc49 \u7528\u6237\u5728\u5217\u8868\u4e2d\u9009\u4e2d\u6587\u4ef6<br \/>\n\ud83d\udc49 \u53ea\u4e0a\u4f20\u9009\u4e2d\u7684<br \/>\n\ud83d\udc49 \u6587\u4ef6\u8fc7\u591a\u65f6\u7ed9\u4e00\u4e2a\u63d0\u793a\u300c\u4e0d\u5efa\u8bae\u4e00\u6b21\u4e0a\u4f20\u5927\u91cf\u6587\u4ef6\u300d<\/p>\n<p>\u6280\u672f\u70b9\uff1a<\/p>\n<ul>\n<li>\u5f02\u6b65\u961f\u5217\u5904\u7406\uff08\u4e32\u884c\uff09<\/li>\n<li>\u6bcf\u4e2a\u6587\u4ef6 copy \u2192 delete local<\/li>\n<li>\u4e0a\u4f20\u72b6\u6001\u7531 MetadataQuery \u76d1\u542c<\/li>\n<\/ul>\n<p>\u4f2a\u4ee3\u7801\uff1a<\/p>\n<pre><code class=\"language-swift\">for file in selectedFiles {\n    queue.async {\n        try? moveToICloud(file)\n    }\n}<\/code><\/pre>\n<p>\u4f18\u70b9\uff1a<\/p>\n<ul>\n<li>\u63a7\u5236\u4e91\u7aef\u6587\u4ef6\u6570\u91cf<\/li>\n<li>\u907f\u514d iCloud \u76ee\u5f55\u8fc7\u5927\u3001\u540c\u6b65\u5931\u8d25<\/li>\n<\/ul>\n<hr \/>\n<h1>\u2b50 \u65b9\u6848 3\uff1a<strong>\u5b50\u76ee\u5f55\u2192\u5355\u6587\u4ef6 copy\uff08\u6587\u4ef6\u6570\u91cf\u5927\u4f46\u5fc5\u987b\u4e0a\u4f20\uff09<\/strong><\/h1>\n<p>\u5982\u679c\u4f60\u5fc5\u987b\u4e0a\u4f20\u5927\u76ee\u5f55\uff08\u4e0d\u63a8\u8350\uff0c\u4f46\u53ef\u884c\uff09\uff1a<\/p>\n<h3>\u5fc5\u987b\u91c7\u7528\u5f02\u6b65\u6279\u5904\u7406 + \u5206\u6bb5\u8fc1\u79fb\uff1a<\/h3>\n<hr \/>\n<h2>\ud83d\udd39 \u6b65\u9aa4 1\uff1a\u904d\u5386\u76ee\u5f55<\/h2>\n<pre><code class=\"language-swift\">let files = try FileManager.default.contentsOfDirectory(\n    at: folder, includingPropertiesForKeys: nil\n)<\/code><\/pre>\n<p>\u5982\u679c\u6587\u4ef6\u8d85\u8fc7 X\uff08\u4f8b\u5982 200\uff09\uff0c\u5efa\u8bae\u5206\u6279\u5904\u7406\uff1a<\/p>\n<pre><code class=\"language-swift\">let batchSize = 50\nlet batches = files.chunked(into: batchSize)<\/code><\/pre>\n<hr \/>\n<h2>\ud83d\udd39 \u6b65\u9aa4 2\uff1a\u4e32\u884c\u961f\u5217\u9010\u4e2a\u5904\u7406<\/h2>\n<pre><code class=\"language-swift\">let queue = DispatchQueue(label: &quot;icloud.move.queue&quot;)\n\nfor batch in batches {\n    queue.async {\n        for file in batch {\n            try? moveToICloud(file)\n        }\n    }\n}<\/code><\/pre>\n<hr \/>\n<h2>\ud83d\udd39 \u6b65\u9aa4 3\uff1a\u907f\u514d\u521b\u5efa\u5927\u91cf iCloud \u6587\u4ef6\uff08\u975e\u5e38\u91cd\u8981\uff09<\/h2>\n<p>iCloud \u5bf9\u300c\u6d77\u91cf\u5c0f\u6587\u4ef6\u300d\u6027\u80fd\u6781\u5dee\uff0c\u4f1a\u5bfc\u81f4\uff1a<\/p>\n<ul>\n<li>\u4e0a\u4f20\u5361\u6b7b<\/li>\n<li>\u8bbe\u5907\u53d8\u6162<\/li>\n<li>MetadataQuery \u65e0\u54cd\u5e94<\/li>\n<li>iCloud \u5d29\u6e83\uff08\u771f\u5b9e\u6848\u4f8b\uff09<\/li>\n<\/ul>\n<p>\u505a\u6cd5\uff1a<\/p>\n<p>\u2714 \u6700\u5c0f\u5316 iCloud \u6587\u4ef6\u6570\u91cf<br \/>\n\u2714 \u5c3d\u53ef\u80fd\u5408\u5e76\u3001\u538b\u7f29<\/p>\n<hr \/>\n<h1>\u26a0\ufe0f \u4e0d\u8981\u505a\u7684\u4e8b\u60c5\uff08\u975e\u5e38\u5173\u952e\uff09<\/h1>\n<h3>\u26d4 1. \u4e0d\u8981\u76f4\u63a5 move \u6574\u4e2a\u76ee\u5f55<\/h3>\n<pre><code class=\"language-swift\">try? FileManager.default.moveItem(at: localFolder, to: iCloudFolder)<\/code><\/pre>\n<p>\u8fd9\u79cd\u505a\u6cd5\u5728 iCloud \u4e0a\u975e\u5e38\u4e0d\u7a33\u5b9a\uff0c\u751a\u81f3\u4f1a\u5bfc\u81f4\u76ee\u5f55\u635f\u574f\u6216\u540c\u6b65\u5931\u8d25\u3002<\/p>\n<hr \/>\n<h3>\u26d4 2. \u4e0d\u8981\u4e00\u6b21\u6027\u5c06\u51e0\u767e\u4e0a\u5343\u4e2a\u6587\u4ef6\u5168\u90e8\u4e0a\u4f20<\/h3>\n<p>iCloud \u4e0d\u9002\u5408\u5927\u89c4\u6a21\u5c0f\u6587\u4ef6\u540c\u6b65\uff08\u8bbe\u8ba1\u5982\u6b64\uff09\u3002<br \/>\n\u4f60\u4f1a\u9047\u5230\uff1a<\/p>\n<ul>\n<li>\u4f20\u8f93\u6781\u6162<\/li>\n<li>iCloud \u8fdb\u5ea6\u4e0d\u51c6\u786e<\/li>\n<li>MetadataQuery \u4e8b\u4ef6\u7206\u70b8<\/li>\n<li>\u8bbe\u5907\u5185\u5b58\u98d9\u5347<\/li>\n<\/ul>\n<hr \/>\n<h3>\u26d4 3. \u4e0d\u8981\u5bf9 iCloud \u76ee\u5f55\u6267\u884c\u5927\u91cf\u5199\u5165\u64cd\u4f5c<\/h3>\n<p>\u5c24\u5176\u662f\u89e3\u538b\u7f29\u76f4\u63a5\u5199\u5165\uff0c\u6709\u6982\u7387\u89e6\u53d1\u5927\u91cf\u4e0a\u4f20\u4efb\u52a1\uff0c\u5bfc\u81f4\u540c\u6b65\u5361\u987f\u6570\u5c0f\u65f6\u3002<\/p>\n<hr \/>\n<h1>\ud83d\udccc \u6700\u63a8\u8350\u7684\u603b\u7ed3\u65b9\u6848<\/h1>\n<table>\n<thead>\n<tr>\n<th>\u65b9\u6848<\/th>\n<th>\u63a8\u8350\u5ea6<\/th>\n<th>\u9002\u7528\u573a\u666f<\/th>\n<\/tr>\n<\/thead>\n<tbody>\n<tr>\n<td><strong>\u6253\u5305\u6210 zip \u4e0a\u4f20<\/strong><\/td>\n<td>\u2b50\u2b50\u2b50\u2b50\u2b50<\/td>\n<td>\u5927\u91cf\u5c0f\u6587\u4ef6\u3001\u76ee\u5f55\u7ed3\u6784\u590d\u6742<\/td>\n<\/tr>\n<tr>\n<td><strong>\u7528\u6237\u624b\u52a8\u9009\u62e9\u6587\u4ef6\u4e0a\u4f20<\/strong><\/td>\n<td>\u2b50\u2b50\u2b50\u2b50<\/td>\n<td>\u666e\u901a\u6587\u4ef6\u7ba1\u7406 App<\/td>\n<\/tr>\n<tr>\n<td><strong>\u5206\u6279\u5f02\u6b65\u4e0a\u4f20<\/strong><\/td>\n<td>\u2b50\u2b50<\/td>\n<td>\u786e\u5b9e\u5fc5\u987b\u5168\u90e8\u4e0a\u4f20\u65f6<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<hr \/>\n","protected":false},"excerpt":{"rendered":"<p>\u5982\u679c\u4f60\u7684 App \u4e0d\u652f\u6301\u76ee\u5f55\u7ea7\u540c\u6b65\uff08iCloud \u4e0d\u5efa\u8bae\u76f4\u63a5\u642c\u6574\u4e2a\u76ee\u5f55\uff09\uff0c\u4f46\u7528\u6237\u53c8\u89e3\u538b\u51fa\u4e00\u4e2a\u5305\u542b \u5927\u91cf\u6587\u4ef6\uff08\u51e0&#8230; <\/p>\n<div class=\"read-more navbutton\"><a href=\"https:\/\/t.n-years.com\/?p=6922\">\u9605\u8bfb\u66f4\u591a<i class=\"fa fa-angle-double-right\"><\/i><\/a><\/div>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[135],"tags":[],"class_list":["post-6922","post","type-post","status-publish","format-standard","hentry","category-135"],"_links":{"self":[{"href":"https:\/\/t.n-years.com\/index.php?rest_route=\/wp\/v2\/posts\/6922","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/t.n-years.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/t.n-years.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/t.n-years.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/t.n-years.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=6922"}],"version-history":[{"count":1,"href":"https:\/\/t.n-years.com\/index.php?rest_route=\/wp\/v2\/posts\/6922\/revisions"}],"predecessor-version":[{"id":6923,"href":"https:\/\/t.n-years.com\/index.php?rest_route=\/wp\/v2\/posts\/6922\/revisions\/6923"}],"wp:attachment":[{"href":"https:\/\/t.n-years.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=6922"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/t.n-years.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=6922"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/t.n-years.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=6922"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}