{"id":1916,"date":"2016-03-25T12:10:29","date_gmt":"2016-03-25T04:10:29","guid":{"rendered":"http:\/\/learn-house.idv.tw\/?p=1916"},"modified":"2016-05-24T18:10:25","modified_gmt":"2016-05-24T10:10:25","slug":"%e8%bd%89ios%e7%9a%84%e6%b2%99%e7%9b%92%e6%a9%9f%e5%88%b6%ef%bc%88sandbox","status":"publish","type":"post","link":"https:\/\/learn-house.idv.tw\/?p=1916","title":{"rendered":"[\u8f49]iOS\u7684\u6c99\u76d2\u6a5f\u5236\uff08SandBox)"},"content":{"rendered":"<p>\u8f49\u8cbc\u4f86\u6e90\uff1a<\/p>\n<p>http:\/\/www.superqq.com\/blog\/2015\/07\/20\/ioskai-fa-zhi-sha-he-ji-zhi-%28sandbox\/<br \/>\nhttp:\/\/www.superqq.com\/blog\/2015\/07\/22\/ioskai-fa-zhi-huo-qu-sha-he-lu-jing<\/p>\n<p>iOS APP\u53ef\u4ee5\u5728\u81ea\u5df1\u7684\u6c99\u76d2\u88e1\u8b80\u5beb\u6587\u4ef6\uff0c\u4f46\u662f\uff0c\u4e0d\u53ef\u4ee5\u8a2a\u554f\u5176\u4ed6APP\u7684\u6c99\u76d2\u3002\u6bcf\u4e00\u500bAPP\u90fd\u662f\u4e00\u500b\u4fe1\u606f\u5b64\u5cf6\uff0c\u76f8\u4e92\u662f\u4e0d\u53ef\u4ee5\u9032\u884c\u901a\u4fe1\u7684\uff0c\u552f\u7368\u53ef\u4ee5\u901a\u904eURL Scheme\u3002\u6c99\u76d2\u88e1\u9762\u7684\u6587\u4ef6\u53ef\u4ee5\u662f\u7167\u7247\u3001\u8072\u97f3\u6587\u4ef6\u3001\u6587\u672c\u3001\u5c6c\u6027\u5217\u8868\u7b49\u3002<\/p>\n<p><!--more--><\/p>\n<h2>\u6c99\u76d2\u6a5f\u5236\u7c21\u4ecb<\/h2>\n<p><strong>\u6c99\u76d2\u7c21\u8ff0\uff1a<\/strong><\/p>\n<ol>\n<li>\u6bcf\u4e00\u500bAPP\u90fd\u6709\u4e00\u500b\u5b58\u5132\u7a7a\u9593\uff0c\u5c31\u662f\u6c99\u76d2\u3002<\/li>\n<li>APP\u4e4b\u9593\u4e0d\u80fd\u76f8\u4e92\u901a\u4fe1\u3002<\/li>\n<li>\u6c99\u76d2\u6839\u76ee\u9304\u7d50\u69cb\uff1aDocuments\u3001Library\u3001temp\u3002<\/li>\n<\/ol>\n<p>\u7c21\u8ff0\u4e00\u4e0bDocuments\u3001Library\u3001tmp\u7684\u5340\u5225\uff1a<\/p>\n<ol>\n<li><strong>Documents\uff1a<\/strong>\u7528\u65bc\u5b58\u5132\u7528\u6236\u6578\u64da\uff0ciTunes\u5099\u4efd\u548c\u6062\u5fa9\u7684\u6642\u5019\u6703\u5305\u62ec\u6b64\u76ee\u9304\uff0c\u6240\u4ee5\uff0c\u860b\u679c\u5efa\u8b70\u5c07\u7a0b\u5e8f\u4e2d\u5efa\u7acb\u7684\u6216\u5728\u7a0b\u5e8f\u4e2d\u700f\u89bd\u5230\u7684\u6587\u4ef6\u6578\u64da\u4fdd\u5b58\u5728\u8a72\u76ee\u9304\u4e0b\u3002<\/li>\n<li><strong>Library\uff1a<\/strong>\u5305\u542b\u5169\u500b\u5b50\u76ee\u9304\uff1aCaches \u548c Preferences\u3002Caches\u7528\u4f86\u5b58\u653e\u7528\u6236\u9700\u8981\u63db\u6210\u7684\u6587\u4ef6\u3002Preferences\u662fAPP\u7684\u504f\u597d\u8a2d\u7f6e\uff0c\u53ef\u4ee5\u901a\u904eNSUserDefaults\u4f86\u8b80\u53d6\u548c\u8a2d\u7f6e\u3002<\/li>\n<li><strong>tmp\uff1a<\/strong> \u7528\u65bc\u5b58\u653e\u81e8\u6642\u6587\u4ef6\uff0c\u9019\u500b\u53ef\u4ee5\u653e\u4e00\u4e9b\u7576APP\u9000\u51fa\u5f8c\u4e0d\u518d\u9700\u8981\u7684\u6587\u4ef6\u3002<\/li>\n<\/ol>\n<p>\u5728\u958b\u767c\u4e2d\uff0c\u6211\u5011\u9700\u8981\u5c0d\u6c99\u76d2\u9032\u884c\u64cd\u4f5c\uff0c\u6240\u4ee5\u6211\u5011\u9700\u8981\u7372\u53d6\u5230\u6c99\u76d2\u8def\u5f91\uff0c\u63a5\u4e0b\u4f86\u6211\u5011\u4f86\u8b1b\u89e3\u5982\u4f55\u7372\u53d6Documents\u3001Library\u3001tmp\u7684\u8def\u5f91\u3002<\/p>\n<h3>\u7372\u53d6\u6c99\u76d2\u6839\u76ee\u9304<\/h3>\n<p>\u7372\u53d6\u6c99\u76d2\u6839\u76ee\u9304\uff0c\u76f4\u63a5\u8abf\u7528NSHomeDirectory()\uff1a<\/p>\n<p>[c]\/\/\u7372\u53d6\u6c99\u76d2\u6839\u76ee\u9304<br \/>\nNSString *directory = NSHomeDirectory();<br \/>\nNSLog(@&quot;directory:%@&quot;, directory);[\/c]<\/p>\n<p>\u63a7\u5236\u53f0\u8f38\u51fa\uff1a<br \/>\n2015-07-22 00:40:16.185 iOSStrongDemo[1605:555658] directory:<strong>\/var\/mobile\/Containers\/Data\/Application\/F9418815-51A9-4A0A-A76C-6FD37C400928<\/strong><br \/>\n\u9019\u500b\u662f\u771f\u6a5f\u7684\u8def\u5f91\uff0c\u5927\u5bb6\u6709\u6642\u9593\u7684\u8a71\u53ef\u4ee5\u770b\u770b\u6a21\u64ec\u5668\u7684\u6839\u76ee\u9304\u8def\u5f91\u3002<\/p>\n<h3>\u7372\u53d6Documents\u8def\u5f91<\/h3>\n<p>\u7372\u53d6Documents\u8def\u5f91\u5982\u4e0b\uff1a<\/p>\n<p>[c]\/\/\u7372\u53d6Documents\u8def\u5f91<br \/>\nNSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);<br \/>\nNSString *path = [paths objectAtIndex:0];<br \/>\nNSLog(@&quot;path:%@&quot;, path);[\/c]<\/p>\n<p>\u63a7\u5236\u53f0\u8f38\u51fa\uff1a<br \/>\n2015-07-22 00:41:41.397 iOSStrongDemo[1613:556159] path:<strong>\/var\/mobile\/Containers\/Data\/Application\/A62B886B-A8F0-4215-B59D-1F505C3997BD\/Documents<\/strong><br \/>\n\u7372\u53d6Documents\u6587\u4ef6\u593e\u76ee\u9304,\u7b2c\u4e00\u500b\u53c3\u6578\u662f\u8aaa\u660e\u7372\u53d6Doucments\u6587\u4ef6\u593e\u76ee\u9304\uff0c\u7b2c\u4e8c\u500b\u53c3\u6578\u8aaa\u660e\u662f\u5728\u7576\u524d\u61c9\u7528\u6c99\u76d2\u4e2d\u7372\u53d6\u3002<\/p>\n<h3>\u7372\u53d6Library\u8def\u5f91<\/h3>\n<p>[c]\/\/\u7372\u53d6Library\u8def\u5f91<br \/>\nNSArray *paths = NSSearchPathForDirectoriesInDomains(NSLibraryDirectory, NSUserDomainMask, YES);<br \/>\nNSString *path = [paths objectAtIndex:0];<br \/>\nNSLog(@&quot;path\uff1a%@&quot;, path);[\/c]<\/p>\n<p>\u63a7\u5236\u53f0\u8f38\u51fa\uff1a<br \/>\n2015-07-22 00:43:15.803 iOSStrongDemo[1619:556638]<strong> \/var\/mobile\/Containers\/Data\/Application\/17300507-4643-4DE7-BC68-E13DB19C8D98\/Library<\/strong><\/p>\n<h3>\u7372\u53d6Caches\u8def\u5f91<\/h3>\n<p>[c]\/\/\u7372\u53d6Caches\u8def\u5f91<br \/>\nNSArray *paths = NSSearchPathForDirectoriesInDomains(NSCachesDirectory, NSUserDomainMask, YES);<br \/>\nNSString *path = [paths objectAtIndex:0];<br \/>\nNSLog(@&quot;path\uff1a%@&quot;, path);[\/c]<\/p>\n<p>\u63a7\u5236\u53f0\u8f38\u51fa\uff1a<br \/>\n2015-07-22 00:44:31.383 iOSStrongDemo[1626:557083] path\uff1a<strong>\/var\/mobile\/Containers\/Data\/Application\/1E945B52-E29D-4041-A489-1AA1B11BB960\/Library\/Caches<\/strong><\/p>\n<h3>\u7372\u53d6tmp\u8def\u5f91<\/h3>\n<p>[c]NSString *tmp = NSTemporaryDirectory();<br \/>\nNSLog(@&quot;tmp\uff1a%@&quot;, tmp);[\/c]<\/p>\n<p>\u63a7\u5236\u53f0\u8f38\u51fa\uff1a<br \/>\n2015-07-22 00:46:07.846 iOSStrongDemo[1632:557537] tmp\uff1a<strong>\/private\/var\/mobile\/Containers\/Data\/Applicat<\/strong><\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u8f49\u8cbc\u4f86\u6e90\uff1a http:\/\/www.superqq.com\/blog\/2015\/07\/20\/ioskai-fa-<span class=\"post-excerpt-end\">&hellip;<\/span><\/p>\n<p class=\"more-link\"><a href=\"https:\/\/learn-house.idv.tw\/?p=1916\" class=\"themebutton\">Read More<\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[5],"tags":[],"class_list":["post-1916","post","type-post","status-publish","format-standard","hentry","category-5"],"_links":{"self":[{"href":"https:\/\/learn-house.idv.tw\/index.php?rest_route=\/wp\/v2\/posts\/1916","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/learn-house.idv.tw\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/learn-house.idv.tw\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/learn-house.idv.tw\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/learn-house.idv.tw\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=1916"}],"version-history":[{"count":0,"href":"https:\/\/learn-house.idv.tw\/index.php?rest_route=\/wp\/v2\/posts\/1916\/revisions"}],"wp:attachment":[{"href":"https:\/\/learn-house.idv.tw\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=1916"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/learn-house.idv.tw\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=1916"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/learn-house.idv.tw\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=1916"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}