{"id":6918,"date":"2025-11-19T10:19:01","date_gmt":"2025-11-19T02:19:01","guid":{"rendered":"https:\/\/t.n-years.com\/?p=6918"},"modified":"2025-11-19T10:19:01","modified_gmt":"2025-11-19T02:19:01","slug":"icloud-document-%e5%bc%80%e5%8f%91%e8%a6%81%e7%82%b9","status":"publish","type":"post","link":"https:\/\/t.n-years.com\/?p=6918","title":{"rendered":"iCloud Document \u5f00\u53d1\u8981\u70b9"},"content":{"rendered":"<p>iCloud Document \u5f00\u53d1\u4e0e\u672c\u5730\u6c99\u76d2\u6587\u4ef6\u64cd\u4f5c\u76f8\u6bd4\uff0c\u6709\u4e00\u4e9b\u6838\u5fc3\u5dee\u522b\u548c\u6ce8\u610f\u70b9\uff0c\u5c24\u5176\u5728\u6587\u4ef6\u7ba1\u7406\u3001\u540c\u6b65\u3001\u6027\u80fd\u548c\u7528\u6237\u4f53\u9a8c\u4e0a\u3002\u4e0b\u9762\u6211\u8be6\u7ec6\u68b3\u7406\uff1a<\/p>\n<hr \/>\n<h3>1. <strong>\u5b58\u50a8\u4f4d\u7f6e\u5dee\u5f02<\/strong><\/h3>\n<ul>\n<li>\n<p><strong>\u6c99\u76d2\u6587\u4ef6<\/strong><\/p>\n<ul>\n<li>\u5168\u90e8\u6587\u4ef6\u90fd\u5b58\u653e\u5728\u5e94\u7528\u6c99\u76d2\u7684 <code>Documents<\/code>\u3001<code>Caches<\/code>\u3001<code>tmp<\/code> \u7b49\u76ee\u5f55\u4e0b\u3002<\/li>\n<li>\u6587\u4ef6\u64cd\u4f5c\u5b8c\u5168\u7531\u5e94\u7528\u63a7\u5236\u3002<\/li>\n<\/ul>\n<\/li>\n<li>\n<p><strong>iCloud Document<\/strong><\/p>\n<ul>\n<li>\u6587\u4ef6\u5b58\u653e\u5728 <strong>\u7528\u6237\u7684 iCloud Drive \u4e0a<\/strong>\uff0c\u672c\u5730\u53ef\u80fd\u4ec5\u4fdd\u7559\u7f13\u5b58\u526f\u672c\uff08\u6839\u636e\u7cfb\u7edf\u5b58\u50a8\u7b56\u7565\uff09\u3002<\/li>\n<li>\u6587\u4ef6\u8def\u5f84\u901a\u5e38\u5728 <code>NSUbiquitousContainerURL<\/code> \u5bf9\u5e94\u7684 iCloud \u5bb9\u5668\u5185\u3002<\/li>\n<li><strong>\u672c\u5730\u672a\u5fc5\u59cb\u7ec8\u5b58\u5728\u5b8c\u6574\u6587\u4ef6<\/strong>\uff0c\u53ef\u80fd\u9700\u8981\u4e0b\u8f7d\u3002<\/li>\n<\/ul>\n<\/li>\n<\/ul>\n<hr \/>\n<h3>2. <strong>\u6587\u4ef6\u53ef\u7528\u6027<\/strong><\/h3>\n<ul>\n<li><strong>\u6c99\u76d2\u6587\u4ef6<\/strong>\uff1a\u7acb\u5373\u53ef\u7528\uff0c\u65e0\u9700\u7f51\u7edc\u3002<\/li>\n<li>\n<p><strong>iCloud Document<\/strong>\uff1a<\/p>\n<ul>\n<li>\u6587\u4ef6\u53ef\u80fd <strong>\u53ea\u5728\u4e91\u7aef\u5b58\u5728<\/strong>\uff0c\u672c\u5730\u9700\u8981\u8c03\u7528 <code>startDownloadingUbiquitousItem(at:)<\/code> \u4e0b\u8f7d\u3002<\/li>\n<li>\u53ef\u4ee5\u901a\u8fc7 <code>NSFileManager<\/code> \u7684 <code>isUbiquitousItem(at:)<\/code> \u5224\u65ad\u662f\u5426\u5728 iCloud\u3002<\/li>\n<li>\u53ef\u4ee5\u7528 <code>evictUbiquitousItem(at:)<\/code> \u6e05\u7406\u672c\u5730\u526f\u672c\uff0c\u91ca\u653e\u78c1\u76d8\u7a7a\u95f4\u3002<\/li>\n<\/ul>\n<\/li>\n<\/ul>\n<hr \/>\n<h3>3. <strong>\u6587\u4ef6\u540c\u6b65<\/strong><\/h3>\n<ul>\n<li><strong>\u6c99\u76d2\u6587\u4ef6<\/strong>\uff1a\u65e0\u540c\u6b65\uff0c\u6570\u636e\u4ec5\u5728\u8bbe\u5907\u672c\u5730\u3002<\/li>\n<li>\n<p><strong>iCloud Document<\/strong>\uff1a<\/p>\n<ul>\n<li>\u6587\u4ef6\u4f1a <strong>\u81ea\u52a8\u540c\u6b65\u5230\u7528\u6237\u5176\u4ed6\u8bbe\u5907<\/strong>\u3002<\/li>\n<li>\u9700\u8981\u5904\u7406\u540c\u6b65\u51b2\u7a81\uff0c\u901a\u5e38\u901a\u8fc7 <code>NSFileVersion<\/code> \u6216 <code>UIDocument<\/code> \u7684 <code>handleError(_:userInteractionPermitted:)<\/code>\u3002<\/li>\n<li>\u4e0d\u80fd\u5047\u8bbe\u5199\u5165\u64cd\u4f5c\u7acb\u5373\u751f\u6548\u5728\u5176\u4ed6\u8bbe\u5907\u4e0a\uff0c\u5fc5\u987b\u8003\u8651\u5f02\u6b65\u540c\u6b65\u5ef6\u8fdf\u3002<\/li>\n<\/ul>\n<\/li>\n<\/ul>\n<hr \/>\n<h3>4. <strong>\u6587\u4ef6\u64cd\u4f5c\u63a5\u53e3<\/strong><\/h3>\n<ul>\n<li>\n<p><strong>\u6c99\u76d2\u6587\u4ef6<\/strong>\uff1a<\/p>\n<ul>\n<li>\u4f7f\u7528 <code>FileManager<\/code>\u3001<code>Data.write(to:)<\/code>\u3001<code>FileHandle<\/code> \u7b49\u6807\u51c6 API\u3002<\/li>\n<li>\u6ca1\u6709\u7f51\u7edc\u4f9d\u8d56\u6216\u540c\u6b65\u95ee\u9898\u3002<\/li>\n<\/ul>\n<\/li>\n<li>\n<p><strong>iCloud Document<\/strong>\uff1a<\/p>\n<ul>\n<li>\n<p>\u63a8\u8350\u4f7f\u7528 <code>UIDocument<\/code> \u6216 <code>NSFileCoordinator<\/code> \u6765\u64cd\u4f5c\u6587\u4ef6\uff0c\u4ee5\u652f\u6301\uff1a<\/p>\n<\/li>\n<li>\n<p><strong>\u5e76\u53d1\u8bbf\u95ee\u534f\u8c03<\/strong>\uff08\u9632\u6b62\u51b2\u7a81\uff09<\/p>\n<\/li>\n<li>\n<p><strong>\u5f02\u6b65\u4e0b\u8f7d \/ \u4e0a\u4f20<\/strong><\/p>\n<\/li>\n<li>\n<p><code>NSFileCoordinator<\/code> + <code>NSFilePresenter<\/code> \u53ef\u76d1\u63a7\u6587\u4ef6\u53d8\u66f4\u3001\u540c\u6b65\u72b6\u6001\u3002<\/p>\n<\/li>\n<\/ul>\n<\/li>\n<\/ul>\n<hr \/>\n<h3>5. <strong>\u6027\u80fd\u4e0e\u5927\u6587\u4ef6\u5904\u7406<\/strong><\/h3>\n<ul>\n<li>\n<p>iCloud \u53ef\u80fd\u4e0d\u4fdd\u7559\u5b8c\u6574\u672c\u5730\u526f\u672c\uff1a<\/p>\n<ul>\n<li>\u8bbf\u95ee\u5927\u6587\u4ef6\u65f6\u9700\u8981\u68c0\u67e5\u672c\u5730\u5b58\u5728\u6027\uff0c\u5426\u5219\u4f1a\u89e6\u53d1\u4e0b\u8f7d\u3002<\/li>\n<li>\u53ef\u4ee5\u901a\u8fc7 <code>NSMetadataQuery<\/code> \u83b7\u53d6\u6587\u4ef6\u72b6\u6001\uff08\u672c\u5730 \/ \u4e91\u7aef \/ \u4fee\u6539\u65e5\u671f\uff09\u3002<\/li>\n<\/ul>\n<\/li>\n<\/ul>\n<hr \/>\n<h3>6. <strong>\u7528\u6237\u4f53\u9a8c\u6ce8\u610f\u70b9<\/strong><\/h3>\n<ul>\n<li>\n<p>\u5fc5\u987b\u8003\u8651\uff1a<\/p>\n<ul>\n<li>\u4e0b\u8f7d\u8fdb\u5ea6\u63d0\u793a\uff08\u6587\u4ef6\u53ef\u80fd\u5c1a\u672a\u4e0b\u8f7d\uff09<\/li>\n<li>\u51b2\u7a81\u63d0\u793a\u6216\u81ea\u52a8\u5408\u5e76<\/li>\n<li>\u672c\u5730\u5b58\u50a8\u9650\u5236\u548c\u6e05\u7406\uff08\u901a\u8fc7 <code>evictUbiquitousItem<\/code>\uff09<\/li>\n<\/ul>\n<\/li>\n<li>\u907f\u514d\u7528\u6237\u8bef\u4ee5\u4e3a\u6240\u6709\u6587\u4ef6\u90fd\u5373\u65f6\u53ef\u7528\u3002<\/li>\n<\/ul>\n<hr \/>\n<h3>7. <strong>\u603b\u7ed3\u5dee\u5f02\u8868<\/strong><\/h3>\n<table>\n<thead>\n<tr>\n<th>\u529f\u80fd<\/th>\n<th>\u6c99\u76d2\u6587\u4ef6<\/th>\n<th>iCloud Document<\/th>\n<\/tr>\n<\/thead>\n<tbody>\n<tr>\n<td>\u5b58\u50a8\u4f4d\u7f6e<\/td>\n<td>\u672c\u5730\u6c99\u76d2<\/td>\n<td>iCloud Drive + \u672c\u5730\u7f13\u5b58<\/td>\n<\/tr>\n<tr>\n<td>\u6587\u4ef6\u7acb\u5373\u53ef\u7528<\/td>\n<td>\u662f<\/td>\n<td>\u4e0d\u4e00\u5b9a\uff0c\u53ef\u80fd\u9700\u4e0b\u8f7d<\/td>\n<\/tr>\n<tr>\n<td>\u540c\u6b65<\/td>\n<td>\u5426<\/td>\n<td>\u81ea\u52a8\u540c\u6b65\u591a\u8bbe\u5907<\/td>\n<\/tr>\n<tr>\n<td>\u5e76\u53d1\u534f\u8c03<\/td>\n<td>\u53ef\u9009<\/td>\n<td>\u5fc5\u987b\uff08<code>NSFileCoordinator<\/code>\/<code>UIDocument<\/code>\uff09<\/td>\n<\/tr>\n<tr>\n<td>\u5927\u6587\u4ef6\u5904\u7406<\/td>\n<td>\u76f4\u63a5\u8bfb\u53d6<\/td>\n<td>\u53ef\u80fd\u5ef6\u8fdf\u4e0b\u8f7d\uff0c\u53ef\u6e05\u7406\u672c\u5730\u526f\u672c<\/td>\n<\/tr>\n<tr>\n<td>\u51b2\u7a81\u5904\u7406<\/td>\n<td>\u4e0d\u9700\u8981<\/td>\n<td>\u9700\u8981\uff08<code>NSFileVersion<\/code> \u6216 <code>UIDocument<\/code>\uff09<\/td>\n<\/tr>\n<tr>\n<td>\u7528\u6237\u63d0\u793a<\/td>\n<td>\u4e0d\u9700\u8981<\/td>\n<td>\u9700\u63d0\u793a\u4e0b\u8f7d\/\u4e0a\u4f20\u72b6\u6001<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<hr \/>\n<p>\ud83d\udca1 <strong>\u6838\u5fc3\u5f00\u53d1\u8981\u70b9\u603b\u7ed3<\/strong>\uff1a<\/p>\n<ol>\n<li>\u4f7f\u7528 <code>UIDocument<\/code> \u6216 <code>NSFileCoordinator<\/code> \u6765\u4fdd\u8bc1\u6587\u4ef6\u534f\u8c03\u548c\u540c\u6b65\u5b89\u5168\u3002<\/li>\n<li>\u5bf9\u6587\u4ef6\u7684\u53ef\u7528\u6027\u3001\u4e0b\u8f7d\u72b6\u6001\u548c\u672c\u5730\u5360\u7528\u505a\u5224\u65ad\u3002<\/li>\n<li>\u5904\u7406\u540c\u6b65\u51b2\u7a81\uff0c\u5c24\u5176\u5728\u591a\u8bbe\u5907\u573a\u666f\u3002<\/li>\n<li>\u5bf9\u5927\u6587\u4ef6\u548c\u7f13\u5b58\u7b56\u7565\u505a\u4f18\u5316\uff0c\u907f\u514d\u5360\u7528\u672c\u5730\u78c1\u76d8\u3002<\/li>\n<li>\u4f7f\u7528 <code>NSMetadataQuery<\/code> \u6765\u67e5\u8be2 iCloud \u6587\u4ef6\u72b6\u6001\u3002<\/li>\n<\/ol>\n<hr \/>\n<p>\u5982\u679c\u4f60\u9700\u8981\uff0c\u6211\u53ef\u4ee5\u5e2e\u4f60\u753b\u4e00\u5f20 <strong>iCloud Document \u4e0e\u6c99\u76d2\u6587\u4ef6\u7684\u64cd\u4f5c\u6d41\u7a0b\u5bf9\u6bd4\u56fe<\/strong>\uff0c\u66f4\u76f4\u89c2\u5730\u770b\u5230\u4e0b\u8f7d\u3001\u4e0a\u4f20\u3001\u6e05\u7406\u7684\u6d41\u7a0b\u3002<\/p>\n<p>\u4f60\u5e0c\u671b\u6211\u753b\u5417\uff1f<\/p>\n","protected":false},"excerpt":{"rendered":"<p>iCloud Document \u5f00\u53d1\u4e0e\u672c\u5730\u6c99\u76d2\u6587\u4ef6\u64cd\u4f5c\u76f8\u6bd4\uff0c\u6709\u4e00\u4e9b\u6838\u5fc3\u5dee\u522b\u548c\u6ce8\u610f\u70b9\uff0c\u5c24\u5176\u5728\u6587\u4ef6\u7ba1\u7406\u3001\u540c\u6b65\u3001\u6027\u80fd&#8230; <\/p>\n<div class=\"read-more navbutton\"><a href=\"https:\/\/t.n-years.com\/?p=6918\">\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":[5],"tags":[],"class_list":["post-6918","post","type-post","status-publish","format-standard","hentry","category-5"],"_links":{"self":[{"href":"https:\/\/t.n-years.com\/index.php?rest_route=\/wp\/v2\/posts\/6918","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=6918"}],"version-history":[{"count":1,"href":"https:\/\/t.n-years.com\/index.php?rest_route=\/wp\/v2\/posts\/6918\/revisions"}],"predecessor-version":[{"id":6919,"href":"https:\/\/t.n-years.com\/index.php?rest_route=\/wp\/v2\/posts\/6918\/revisions\/6919"}],"wp:attachment":[{"href":"https:\/\/t.n-years.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=6918"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/t.n-years.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=6918"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/t.n-years.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=6918"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}