{"id":873,"date":"2026-02-11T11:05:25","date_gmt":"2026-02-11T03:05:25","guid":{"rendered":"https:\/\/www.ixriver.com\/?p=873"},"modified":"2026-02-11T11:05:25","modified_gmt":"2026-02-11T03:05:25","slug":"ios-%e7%94%b5%e9%87%8f%e4%bc%98%e5%8c%96","status":"publish","type":"post","link":"https:\/\/p.ixriver.com\/?p=873","title":{"rendered":"iOS \u7535\u91cf\u4f18\u5316"},"content":{"rendered":"<div id=\"ez-toc-container\" class=\"ez-toc-v2_0_65 counter-hierarchy ez-toc-counter ez-toc-grey ez-toc-container-direction\">\n<div class=\"ez-toc-title-container\">\n<p class=\"ez-toc-title \" >\u76ee\u5f55<\/p>\n<span class=\"ez-toc-title-toggle\"><a href=\"#\" class=\"ez-toc-pull-right ez-toc-btn ez-toc-btn-xs ez-toc-btn-default ez-toc-toggle\" aria-label=\"Toggle Table of Content\"><span class=\"ez-toc-js-icon-con\"><span class=\"\"><span class=\"eztoc-hide\" style=\"display:none;\">Toggle<\/span><span class=\"ez-toc-icon-toggle-span\"><svg style=\"fill: #999;color:#999\" xmlns=\"http:\/\/www.w3.org\/2000\/svg\" class=\"list-377408\" width=\"20px\" height=\"20px\" viewBox=\"0 0 24 24\" fill=\"none\"><path d=\"M6 6H4v2h2V6zm14 0H8v2h12V6zM4 11h2v2H4v-2zm16 0H8v2h12v-2zM4 16h2v2H4v-2zm16 0H8v2h12v-2z\" fill=\"currentColor\"><\/path><\/svg><svg style=\"fill: #999;color:#999\" class=\"arrow-unsorted-368013\" xmlns=\"http:\/\/www.w3.org\/2000\/svg\" width=\"10px\" height=\"10px\" viewBox=\"0 0 24 24\" version=\"1.2\" baseProfile=\"tiny\"><path d=\"M18.2 9.3l-6.2-6.3-6.2 6.3c-.2.2-.3.4-.3.7s.1.5.3.7c.2.2.4.3.7.3h11c.3 0 .5-.1.7-.3.2-.2.3-.5.3-.7s-.1-.5-.3-.7zM5.8 14.7l6.2 6.3 6.2-6.3c.2-.2.3-.5.3-.7s-.1-.5-.3-.7c-.2-.2-.4-.3-.7-.3h-11c-.3 0-.5.1-.7.3-.2.2-.3.5-.3.7s.1.5.3.7z\"\/><\/svg><\/span><\/span><\/span><\/a><\/span><\/div>\n<nav><ul class='ez-toc-list ez-toc-list-level-1 ' ><li class='ez-toc-page-1 ez-toc-heading-level-1'><a class=\"ez-toc-link ez-toc-heading-1\" href=\"https:\/\/p.ixriver.com\/?p=873\/#iOS_%E7%94%B5%E9%87%8F%E4%BC%98%E5%8C%96\" title=\"iOS \u7535\u91cf\u4f18\u5316\">iOS \u7535\u91cf\u4f18\u5316<\/a><ul class='ez-toc-list-level-2' ><li class='ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-2\" href=\"https:\/\/p.ixriver.com\/?p=873\/#1_CPU_%E4%BC%98%E5%8C%96\" title=\"1. CPU \u4f18\u5316\">1. CPU \u4f18\u5316<\/a><ul class='ez-toc-list-level-3' ><li class='ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-3\" href=\"https:\/\/p.ixriver.com\/?p=873\/#11_CPU_%E4%BD%BF%E7%94%A8%E7%8E%87%E4%B8%8E%E5%8A%9F%E8%80%97\" title=\"1.1 CPU \u4f7f\u7528\u7387\u4e0e\u529f\u8017\">1.1 CPU \u4f7f\u7528\u7387\u4e0e\u529f\u8017<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-4\" href=\"https:\/\/p.ixriver.com\/?p=873\/#12_%E5%90%8E%E5%8F%B0%E4%BB%BB%E5%8A%A1%E4%BC%98%E5%8C%96\" title=\"1.2 \u540e\u53f0\u4efb\u52a1\u4f18\u5316\">1.2 \u540e\u53f0\u4efb\u52a1\u4f18\u5316<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-5\" href=\"https:\/\/p.ixriver.com\/?p=873\/#13_%E8%B0%83%E6%95%B4%E4%BB%BB%E5%8A%A1%E7%9A%84_QoS_%E7%BA%A7%E5%88%AB\" title=\"1.3 \u8c03\u6574\u4efb\u52a1\u7684 QoS \u7ea7\u522b\">1.3 \u8c03\u6574\u4efb\u52a1\u7684 QoS \u7ea7\u522b<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-6\" href=\"https:\/\/p.ixriver.com\/?p=873\/#14_%E5%87%8F%E5%B0%91%E5%AE%9A%E6%97%B6%E5%99%A8%E7%9A%84%E4%BD%BF%E7%94%A8\" title=\"1.4 \u51cf\u5c11\u5b9a\u65f6\u5668\u7684\u4f7f\u7528\">1.4 \u51cf\u5c11\u5b9a\u65f6\u5668\u7684\u4f7f\u7528<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-7\" href=\"https:\/\/p.ixriver.com\/?p=873\/#15_%E5%87%8F%E5%B0%91_IO_%E6%93%8D%E4%BD%9C\" title=\"1.5 \u51cf\u5c11 IO \u64cd\u4f5c\">1.5 \u51cf\u5c11 IO \u64cd\u4f5c<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-8\" href=\"https:\/\/p.ixriver.com\/?p=873\/#16_%E5%A4%84%E7%90%86%E4%BD%8E%E7%94%B5%E9%87%8F%E6%A8%A1%E5%BC%8F\" title=\"1.6 \u5904\u7406\u4f4e\u7535\u91cf\u6a21\u5f0f\">1.6 \u5904\u7406\u4f4e\u7535\u91cf\u6a21\u5f0f<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-9\" href=\"https:\/\/p.ixriver.com\/?p=873\/#17_%E5%A4%84%E7%90%86%E5%8F%91%E7%83%AD%E7%8A%B6%E6%80%81\" title=\"1.7 \u5904\u7406\u53d1\u70ed\u72b6\u6001\">1.7 \u5904\u7406\u53d1\u70ed\u72b6\u6001<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-10\" href=\"https:\/\/p.ixriver.com\/?p=873\/#18_Energy_Log_%E2%80%93_%E9%AB%98_CPU_%E7%9B%91%E6%8E%A7%E7%AD%96%E7%95%A5\" title=\"1.8 Energy Log &#8211; \u9ad8 CPU \u76d1\u63a7\u7b56\u7565\">1.8 Energy Log &#8211; \u9ad8 CPU \u76d1\u63a7\u7b56\u7565<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-11\" href=\"https:\/\/p.ixriver.com\/?p=873\/#19_IO_%E7%9B%91%E6%8E%A7\" title=\"1.9 IO \u76d1\u63a7\">1.9 IO \u76d1\u63a7<\/a><\/li><\/ul><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-12\" href=\"https:\/\/p.ixriver.com\/?p=873\/#2_%E7%BD%91%E7%BB%9C%E4%BC%98%E5%8C%96\" title=\"2. \u7f51\u7edc\u4f18\u5316\">2. \u7f51\u7edc\u4f18\u5316<\/a><ul class='ez-toc-list-level-3' ><li class='ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-13\" href=\"https:\/\/p.ixriver.com\/?p=873\/#21_%E5%87%8F%E5%B0%91%E7%BD%91%E7%BB%9C%E6%93%8D%E4%BD%9C\" title=\"2.1 \u51cf\u5c11\u7f51\u7edc\u64cd\u4f5c\">2.1 \u51cf\u5c11\u7f51\u7edc\u64cd\u4f5c<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-14\" href=\"https:\/\/p.ixriver.com\/?p=873\/#22_%E5%BB%B6%E8%BF%9F%E7%BD%91%E7%BB%9C%E6%93%8D%E4%BD%9C\" title=\"2.2 \u5ef6\u8fdf\u7f51\u7edc\u64cd\u4f5c\">2.2 \u5ef6\u8fdf\u7f51\u7edc\u64cd\u4f5c<\/a><\/li><\/ul><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-15\" href=\"https:\/\/p.ixriver.com\/?p=873\/#3_%E5%9B%BE%E5%BD%A2%E3%80%81%E5%8A%A8%E7%94%BB%E5%92%8C%E8%A7%86%E9%A2%91%E4%BC%98%E5%8C%96\" title=\"3. \u56fe\u5f62\u3001\u52a8\u753b\u548c\u89c6\u9891\u4f18\u5316\">3. \u56fe\u5f62\u3001\u52a8\u753b\u548c\u89c6\u9891\u4f18\u5316<\/a><ul class='ez-toc-list-level-3' ><li class='ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-16\" href=\"https:\/\/p.ixriver.com\/?p=873\/#31_%E9%81%BF%E5%85%8D%E8%BF%87%E5%BA%A6%E7%9A%84%E5%9B%BE%E5%BD%A2%E5%92%8C%E5%8A%A8%E7%94%BB\" title=\"3.1 \u907f\u514d\u8fc7\u5ea6\u7684\u56fe\u5f62\u548c\u52a8\u753b\">3.1 \u907f\u514d\u8fc7\u5ea6\u7684\u56fe\u5f62\u548c\u52a8\u753b<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-17\" href=\"https:\/\/p.ixriver.com\/?p=873\/#32_%E6%92%AD%E6%94%BE%E5%85%A8%E5%B1%8F%E8%A7%86%E9%A2%91%E6%97%B6%E7%9A%84%E4%BC%98%E5%8C%96\" title=\"3.2 \u64ad\u653e\u5168\u5c4f\u89c6\u9891\u65f6\u7684\u4f18\u5316\">3.2 \u64ad\u653e\u5168\u5c4f\u89c6\u9891\u65f6\u7684\u4f18\u5316<\/a><\/li><\/ul><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-18\" href=\"https:\/\/p.ixriver.com\/?p=873\/#4_%E4%BD%8D%E7%BD%AE%E5%92%8C%E4%BC%A0%E6%84%9F%E5%99%A8%E4%BC%98%E5%8C%96\" title=\"4. \u4f4d\u7f6e\u548c\u4f20\u611f\u5668\u4f18\u5316\">4. \u4f4d\u7f6e\u548c\u4f20\u611f\u5668\u4f18\u5316<\/a><ul class='ez-toc-list-level-3' ><li class='ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-19\" href=\"https:\/\/p.ixriver.com\/?p=873\/#41_%E5%87%8F%E5%B0%91%E4%BD%8D%E7%BD%AE%E7%B2%BE%E5%BA%A6%E5%92%8C%E6%8C%81%E7%BB%AD%E6%97%B6%E9%97%B4\" title=\"4.1 \u51cf\u5c11\u4f4d\u7f6e\u7cbe\u5ea6\u548c\u6301\u7eed\u65f6\u95f4\">4.1 \u51cf\u5c11\u4f4d\u7f6e\u7cbe\u5ea6\u548c\u6301\u7eed\u65f6\u95f4<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-20\" href=\"https:\/\/p.ixriver.com\/?p=873\/#42_%E5%87%8F%E5%B0%91%E4%BC%A0%E6%84%9F%E5%99%A8%E6%9B%B4%E6%96%B0%E9%A2%91%E7%8E%87\" title=\"4.2 \u51cf\u5c11\u4f20\u611f\u5668\u66f4\u65b0\u9891\u7387\">4.2 \u51cf\u5c11\u4f20\u611f\u5668\u66f4\u65b0\u9891\u7387<\/a><\/li><\/ul><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-21\" href=\"https:\/\/p.ixriver.com\/?p=873\/#5_%E9%80%9A%E7%9F%A5%E4%BC%98%E5%8C%96\" title=\"5. \u901a\u77e5\u4f18\u5316\">5. \u901a\u77e5\u4f18\u5316<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-22\" href=\"https:\/\/p.ixriver.com\/?p=873\/#6_%E5%87%8F%E5%B0%91%E5%A4%96%E9%83%A8%E8%AE%BE%E5%A4%87%E4%BA%A4%E4%BA%92\" title=\"6. \u51cf\u5c11\u5916\u90e8\u8bbe\u5907\u4ea4\u4e92\">6. \u51cf\u5c11\u5916\u90e8\u8bbe\u5907\u4ea4\u4e92<\/a><ul class='ez-toc-list-level-3' ><li class='ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-23\" href=\"https:\/\/p.ixriver.com\/?p=873\/#61_%E8%93%9D%E7%89%99%E6%9C%80%E4%BD%B3%E5%AE%9E%E8%B7%B5\" title=\"6.1 \u84dd\u7259\u6700\u4f73\u5b9e\u8df5\">6.1 \u84dd\u7259\u6700\u4f73\u5b9e\u8df5<\/a><\/li><\/ul><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-24\" href=\"https:\/\/p.ixriver.com\/?p=873\/#7_%E8%83%BD%E8%80%97%E7%9B%91%E6%8E%A7\" title=\"7. \u80fd\u8017\u76d1\u63a7\">7. \u80fd\u8017\u76d1\u63a7<\/a><ul class='ez-toc-list-level-3' ><li class='ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-25\" href=\"https:\/\/p.ixriver.com\/?p=873\/#71_%E8%83%BD%E8%80%97%E8%BF%87%E5%BA%A6%E4%BD%BF%E7%94%A8%E7%9A%84%E4%BF%A1%E5%8F%B7\" title=\"7.1 \u80fd\u8017\u8fc7\u5ea6\u4f7f\u7528\u7684\u4fe1\u53f7\">7.1 \u80fd\u8017\u8fc7\u5ea6\u4f7f\u7528\u7684\u4fe1\u53f7<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-26\" href=\"https:\/\/p.ixriver.com\/?p=873\/#72_%E7%9B%91%E6%8E%A7%E6%96%B9%E6%B3%95\" title=\"7.2 \u76d1\u63a7\u65b9\u6cd5\">7.2 \u76d1\u63a7\u65b9\u6cd5<\/a><\/li><\/ul><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-27\" href=\"https:\/\/p.ixriver.com\/?p=873\/#8_%E4%BC%98%E5%8C%96%E5%BB%BA%E8%AE%AE\" title=\"8. \u4f18\u5316\u5efa\u8bae\">8. \u4f18\u5316\u5efa\u8bae<\/a><ul class='ez-toc-list-level-3' ><li class='ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-28\" href=\"https:\/\/p.ixriver.com\/?p=873\/#81_%E6%80%A7%E8%83%BD%E4%BC%98%E5%8C%96\" title=\"8.1 \u6027\u80fd\u4f18\u5316\">8.1 \u6027\u80fd\u4f18\u5316<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-29\" href=\"https:\/\/p.ixriver.com\/?p=873\/#82_%E4%BB%A3%E7%A0%81%E4%BC%98%E5%8C%96\" title=\"8.2 \u4ee3\u7801\u4f18\u5316\">8.2 \u4ee3\u7801\u4f18\u5316<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-30\" href=\"https:\/\/p.ixriver.com\/?p=873\/#83_%E8%83%BD%E8%80%97%E8%B0%83%E8%AF%95%E6%96%B0%E7%89%B9%E6%80%A7\" title=\"8.3 \u80fd\u8017\u8c03\u8bd5\u65b0\u7279\u6027\">8.3 \u80fd\u8017\u8c03\u8bd5\u65b0\u7279\u6027<\/a><\/li><\/ul><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-31\" href=\"https:\/\/p.ixriver.com\/?p=873\/#9_%E5%85%B6%E4%BB%96\" title=\"9. \u5176\u4ed6\">9. \u5176\u4ed6<\/a><ul class='ez-toc-list-level-3' ><li class='ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-32\" href=\"https:\/\/p.ixriver.com\/?p=873\/#91_iOS_%E5%90%8E%E5%8F%B0%E7%A8%8B%E5%BA%8F\" title=\"9.1 iOS \u540e\u53f0\u7a0b\u5e8f\">9.1 iOS \u540e\u53f0\u7a0b\u5e8f<\/a><\/li><\/ul><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-33\" href=\"https:\/\/p.ixriver.com\/?p=873\/#%E5%8F%82%E8%80%83%E8%B5%84%E6%96%99\" title=\"\u53c2\u8003\u8d44\u6599\">\u53c2\u8003\u8d44\u6599<\/a><\/li><\/ul><\/li><\/ul><\/nav><\/div>\n<h1><span class=\"ez-toc-section\" id=\"iOS_%E7%94%B5%E9%87%8F%E4%BC%98%E5%8C%96\"><\/span>iOS \u7535\u91cf\u4f18\u5316<span class=\"ez-toc-section-end\"><\/span><\/h1>\n<h2><span class=\"ez-toc-section\" id=\"1_CPU_%E4%BC%98%E5%8C%96\"><\/span>1. CPU \u4f18\u5316<span class=\"ez-toc-section-end\"><\/span><\/h2>\n<h3><span class=\"ez-toc-section\" id=\"11_CPU_%E4%BD%BF%E7%94%A8%E7%8E%87%E4%B8%8E%E5%8A%9F%E8%80%97\"><\/span>1.1 CPU \u4f7f\u7528\u7387\u4e0e\u529f\u8017<span class=\"ez-toc-section-end\"><\/span><\/h3>\n<p>CPU \u4f7f\u7528\u7387\u4e0e\u529f\u8017\u6210\u6b63\u6bd4\u5173\u7cfb\u3002CPU \u4f7f\u7528\u7387\u8d8a\u9ad8\uff0c\u529f\u8017\u8d8a\u5927\u3002<\/p>\n<p><img decoding=\"async\" alt=\"CPU \u4f7f\u7528\u7387\u4e0e\u529f\u8017\u5173\u7cfb\" src=\"https:\/\/www.ixriver.com\/wp-content\/uploads\/2026\/02\/image_1-2.png\" \/><\/p>\n<table>\n<thead>\n<tr>\n<th>\u72b6\u6001<\/th>\n<th>\u529f\u8017\u500d\u6570<\/th>\n<\/tr>\n<\/thead>\n<tbody>\n<tr>\n<td>Sleep<\/td>\n<td>1<\/td>\n<\/tr>\n<tr>\n<td>Idle<\/td>\n<td>10 = 1(sleep) \u00d7 10<\/td>\n<\/tr>\n<tr>\n<td>1% CPU \u4f7f\u7528<\/td>\n<td>11 = 10(idle) \u00d7 1.1<\/td>\n<\/tr>\n<tr>\n<td>10% CPU \u4f7f\u7528<\/td>\n<td>20 = 10(idle) \u00d7 2<\/td>\n<\/tr>\n<tr>\n<td>100% CPU \u4f7f\u7528<\/td>\n<td>100 = 10(idle) \u00d7 10<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<h3><span class=\"ez-toc-section\" id=\"12_%E5%90%8E%E5%8F%B0%E4%BB%BB%E5%8A%A1%E4%BC%98%E5%8C%96\"><\/span>1.2 \u540e\u53f0\u4efb\u52a1\u4f18\u5316<span class=\"ez-toc-section-end\"><\/span><\/h3>\n<p>\u540e\u53f0\u9700\u8981\u957f\u65f6\u95f4\u8fd0\u884c\u7684\u4efb\u52a1\uff0c\u5e94\u8be5\u901a\u8fc7\u7cfb\u7edf API \u7533\u8bf7\u540e\u53f0\u6267\u884c\u65f6\u95f4\u3002<\/p>\n<p><strong>\u4f7f\u7528\u540e\u53f0\u4efb\u52a1\u6807\u8bc6\u7b26\uff1a<\/strong><\/p>\n<pre><code class=\"language-objc\">UIBackgroundTaskIdentifier bgTaskID = [[UIApplication sharedApplication] beginBackgroundTaskWithExpirationHandler:^{\n    \/\/ \u8d85\u65f6\u5904\u7406\u56de\u8c03\n}];\n\n\/\/ \u6267\u884c\u540e\u53f0\u4efb\u52a1\n\/\/ ...\n\n\/\/ \u4efb\u52a1\u5b8c\u6210\u540e\u901a\u77e5\u7cfb\u7edf\n[[UIApplication sharedApplication] endBackgroundTask:bgTaskID];\n<\/code><\/pre>\n<p><strong>\u6ce8\u610f\u4e8b\u9879\uff1a<\/strong><\/p>\n<ul>\n<li>\u8d85\u51fa\u540e\u53f0\u4efb\u52a1\u65f6\u95f4\u9650\u5236\u7684\u540e\u53f0\u4efb\u52a1\uff0c\u4f1a\u89e6\u53d1 CPU \u4f7f\u7528\u7387\u8fc7\u9ad8\u7684\u5d29\u6e83<\/li>\n<li>\u5d29\u6e83\u4fe1\u606f\u793a\u4f8b\uff1a<br \/>\n  <code>Exception Type: EXC_RESOURCE<br \/>\n  Exception Subtype: CPU_FATAL<br \/>\n  Exception Message: (Limit 80%) Observed 89% over 60 seconds<\/code><\/li>\n<\/ul>\n<h3><span class=\"ez-toc-section\" id=\"13_%E8%B0%83%E6%95%B4%E4%BB%BB%E5%8A%A1%E7%9A%84_QoS_%E7%BA%A7%E5%88%AB\"><\/span>1.3 \u8c03\u6574\u4efb\u52a1\u7684 QoS \u7ea7\u522b<span class=\"ez-toc-section-end\"><\/span><\/h3>\n<p>\u901a\u8fc7\u8bbe\u7f6e\u5408\u9002\u7684 Quality of Service (QoS) \u7ea7\u522b\uff0c\u53ef\u4ee5\u8ba9\u7cfb\u7edf\u66f4\u597d\u5730\u7ba1\u7406\u4efb\u52a1\u4f18\u5148\u7ea7\u548c\u8d44\u6e90\u5206\u914d\uff0c\u4ece\u800c\u964d\u4f4e\u529f\u8017\u3002<\/p>\n<p><strong>NSOperation \u8bbe\u7f6e QoS\uff1a<\/strong><\/p>\n<pre><code class=\"language-objc\">\/\/ NSOperation\nNSOperation *myOperation = [[NSOperation alloc] init];\nmyOperation.qualityOfService = NSQualityOfServiceUtility;\n\n\/\/ NSOperationQueue\nNSOperationQueue *queue = [NSOperationQueue new];\nqueue.qualityOfService = NSQualityOfServiceUtility;\n<\/code><\/pre>\n<p><strong>GCD Queue \u8bbe\u7f6e QoS\uff1a<\/strong><\/p>\n<pre><code class=\"language-objc\">\/\/ GCD queue\ndispatch_queue_attr_t qosAttribute = dispatch_queue_attr_make_with_qos_class(\n    DISPATCH_QUEUE_CONCURRENT, \n    QOS_CLASS_UTILITY, \n    0\n);\ndispatch_queue_t myQueue = dispatch_queue_create(&quot;com.YourApp.YourQueue&quot;, qosAttribute);\n\n\/\/ dispatch_block_t\ndispatch_block_t myBlock;\nmyBlock = dispatch_block_create_with_qos_class(0, QOS_CLASS_UTILITY, -8, ^{\n    \/\/ ...\n});\ndispatch_async(myQueue, myBlock);\n<\/code><\/pre>\n<p><strong>pthread \u8bbe\u7f6e QoS\uff1a<\/strong><\/p>\n<pre><code class=\"language-objc\">\/\/ pthread\npthread_attr_t qosAttribute;\npthread_attr_init(&amp;qosAttribute);\npthread_attr_set_qos_class_np(&amp;qosAttribute, QOS_CLASS_UTILITY, 0);\npthread_create(&amp;thread, &amp;qosAttribute, f, NULL);\n\n\/\/ \u4fee\u6539\u7ebf\u7a0b\u7684 QoS\npthread_set_qos_class_self_np(QOS_CLASS_BACKGROUND, 0);\n<\/code><\/pre>\n<h3><span class=\"ez-toc-section\" id=\"14_%E5%87%8F%E5%B0%91%E5%AE%9A%E6%97%B6%E5%99%A8%E7%9A%84%E4%BD%BF%E7%94%A8\"><\/span>1.4 \u51cf\u5c11\u5b9a\u65f6\u5668\u7684\u4f7f\u7528<span class=\"ez-toc-section-end\"><\/span><\/h3>\n<p>\u5b9a\u65f6\u5668\u4f1a\u6301\u7eed\u5524\u9192 CPU\uff0c\u589e\u52a0\u529f\u8017\u3002\u4f18\u5316\u5efa\u8bae\uff1a<\/p>\n<ul>\n<li>\u4f7f\u7528\u4e8b\u4ef6\u901a\u77e5\u66ff\u4ee3\u5b9a\u65f6\u5668<\/li>\n<li>\u4f7f\u7528 GCD \u8fdb\u884c\u540c\u6b65\u64cd\u4f5c<\/li>\n<li>\u8bbe\u7f6e\u5408\u7406\u7684\u8d85\u65f6\u65f6\u95f4<\/li>\n<li>\u4e0d\u9700\u8981\u5b9a\u65f6\u5668\u65f6\u53ca\u65f6\u91cd\u7f6e\u5b9a\u65f6\u5668<\/li>\n<li>\u8bbe\u7f6e\u5b9a\u65f6\u5668\u7cbe\u5ea6\uff08tolerance\uff09<\/li>\n<\/ul>\n<p><strong>NSTimer \u8bbe\u7f6e\u7cbe\u5ea6\uff1a<\/strong><\/p>\n<pre><code class=\"language-objc\">[myTimer setTolerance:0.3];\n[[NSRunLoop currentRunLoop] addTimer:myTimer forMode:NSDefaultRunLoopMode];\n<\/code><\/pre>\n<p><strong>dispatch_source_timer\uff1a<\/strong><\/p>\n<pre><code class=\"language-objc\">dispatch_source_t myDispatchSourceTimer = dispatch_source_create(\n    DISPATCH_SOURCE_TYPE_TIMER, \n    0, \n    0, \n    myQueue\n);\ndispatch_source_set_timer(\n    myDispatchSourceTimer, \n    DISPATCH_TIME_NOW, \n    1 * NSEC_PER_SEC, \n    NSEC_PER_SEC \/ 10\n);\ndispatch_source_set_event_handler(myDispatchSourceTimer, ^{\n    [self timerFired];\n});\ndispatch_resume(myDispatchSourceTimer);\n<\/code><\/pre>\n<p><strong>CFRunLoopTimerRef\uff1a<\/strong><\/p>\n<pre><code class=\"language-objc\">CFRunLoopTimerRef myRunLoopTimer = CFRunLoopTimerCreate(\n    kCFAllocatorDefault, \n    fireDate, \n    2.0, \n    0, \n    &amp;timerFired, \n    NULL\n);\nCFRunLoopTimerSetTolerance(myRunLoopTimer, 0.2);\nCFRunLoopAddTimer(CFRunLoopGetCurrent(), myRunLoopTimer, kCFRunLoopDefaultMode);\n<\/code><\/pre>\n<h3><span class=\"ez-toc-section\" id=\"15_%E5%87%8F%E5%B0%91_IO_%E6%93%8D%E4%BD%9C\"><\/span>1.5 \u51cf\u5c11 IO \u64cd\u4f5c<span class=\"ez-toc-section-end\"><\/span><\/h3>\n<p>IO \u64cd\u4f5c\u4f1a\u6d88\u8017\u5927\u91cf\u7535\u91cf\uff0c\u4f18\u5316\u5efa\u8bae\uff1a<\/p>\n<ul>\n<li>\u51cf\u5c11\u6570\u636e\u91cf\u7684\u5199\u5165<\/li>\n<li>\u907f\u514d\u9891\u7e41\u5199\u5185\u5b58<\/li>\n<li>\u5c3d\u91cf\u6309\u987a\u5e8f\u8bfb\u5199\u6570\u636e<\/li>\n<li>\u4f7f\u7528 <code>dispatch_io<\/code> \u8fdb\u884c\u6570\u636e\u8bfb\u5199<\/li>\n<li>\u4e86\u89e3\u7cfb\u7edf\u7684\u7f13\u5b58\u673a\u5236<\/li>\n<\/ul>\n<h3><span class=\"ez-toc-section\" id=\"16_%E5%A4%84%E7%90%86%E4%BD%8E%E7%94%B5%E9%87%8F%E6%A8%A1%E5%BC%8F\"><\/span>1.6 \u5904\u7406\u4f4e\u7535\u91cf\u6a21\u5f0f<span class=\"ez-toc-section-end\"><\/span><\/h3>\n<p>iOS \u63d0\u4f9b\u4e86\u4f4e\u7535\u91cf\u6a21\u5f0f\uff08Low Power Mode\uff09\u7684\u68c0\u6d4b\u548c\u901a\u77e5\u673a\u5236\uff0c\u5e94\u7528\u5e94\u8be5\u54cd\u5e94\u4f4e\u7535\u91cf\u6a21\u5f0f\uff0c\u51cf\u5c11\u4e0d\u5fc5\u8981\u7684\u64cd\u4f5c\u3002<\/p>\n<p><strong>\u76d1\u542c\u4f4e\u7535\u91cf\u6a21\u5f0f\u901a\u77e5\uff1a<\/strong><\/p>\n<pre><code class=\"language-objc\">\/\/ \u76d1\u542c\u901a\u77e5\n[[NSNotificationCenter defaultCenter] addObserver:self\n    selector:@selector(yourMethodName:)\n    name:NSProcessInfoPowerStateDidChangeNotification\n    object:nil];\n<\/code><\/pre>\n<p><strong>\u67e5\u8be2\u4f4e\u7535\u91cf\u6a21\u5f0f\u72b6\u6001\uff1a<\/strong><\/p>\n<pre><code class=\"language-objc\">if ([[NSProcessInfo processInfo] isLowPowerModeEnabled]) {\n    \/\/ \u4f4e\u7535\u91cf\u6a21\u5f0f\u5df2\u542f\u7528\uff0c\u5f00\u59cb\u51cf\u5c11\u6d3b\u52a8\u4ee5\u8282\u7701\u7535\u91cf\n} else {\n    \/\/ \u4f4e\u7535\u91cf\u6a21\u5f0f\u672a\u542f\u7528\n}\n<\/code><\/pre>\n<h3><span class=\"ez-toc-section\" id=\"17_%E5%A4%84%E7%90%86%E5%8F%91%E7%83%AD%E7%8A%B6%E6%80%81\"><\/span>1.7 \u5904\u7406\u53d1\u70ed\u72b6\u6001<span class=\"ez-toc-section-end\"><\/span><\/h3>\n<p>iOS \u63d0\u4f9b\u4e86\u8bbe\u5907\u53d1\u70ed\u72b6\u6001\u7684\u76d1\u63a7\u673a\u5236\uff0c\u5e94\u7528\u5e94\u8be5\u54cd\u5e94\u53d1\u70ed\u72b6\u6001\uff0c\u964d\u4f4e\u6027\u80fd\u8981\u6c42\u3002<\/p>\n<p><strong>\u76d1\u542c\u53d1\u70ed\u72b6\u6001\u901a\u77e5\uff1a<\/strong><\/p>\n<pre><code class=\"language-objc\">[[NSNotificationCenter defaultCenter] addObserver:self\n    selector:@selector(thermalStateChanged:)\n    name:NSProcessInfoThermalStateDidChangeNotification\n    object:nil];\n<\/code><\/pre>\n<h3><span class=\"ez-toc-section\" id=\"18_Energy_Log_%E2%80%93_%E9%AB%98_CPU_%E7%9B%91%E6%8E%A7%E7%AD%96%E7%95%A5\"><\/span>1.8 Energy Log &#8211; \u9ad8 CPU \u76d1\u63a7\u7b56\u7565<span class=\"ez-toc-section-end\"><\/span><\/h3>\n<p>\u7cfb\u7edf\u4f1a\u6839\u636e CPU \u4f7f\u7528\u7387\u76d1\u63a7\u5e94\u7528\u7684\u80fd\u8017\u60c5\u51b5\uff0c\u4e0d\u540c iOS \u7248\u672c\u7684\u89e6\u53d1\u6761\u4ef6\u4e0d\u540c\uff1a<\/p>\n<p><strong>iOS 2018 \u7248\u672c\uff1a<\/strong><br \/>\n&#8211; \u524d\u53f0\u8d85\u8fc7 3 \u5206\u949f\u8d85\u8fc7 80% \u7684 CPU \u4f7f\u7528<br \/>\n&#8211; \u540e\u53f0\u8d85\u8fc7 1 \u5206\u949f\u8d85\u8fc7 80% \u7684 CPU \u4f7f\u7528\uff0c\u5e94\u7528\u7a0b\u5e8f\u4f1a\u88ab\u6740\u6b7b<\/p>\n<p><strong>iOS 2022 \u7248\u672c\uff1a<\/strong><br \/>\n&#8211; \u524d\u53f0\u8d85\u8fc7 3 \u5206\u949f\u8d85\u8fc7 80% \u7684 CPU \u4f7f\u7528\uff0c\u63d0\u793a CPU \u4f7f\u7528\u8fc7\u9ad8<br \/>\n&#8211; \u540e\u53f0\u8d85\u8fc7 15 \u79d2\u949f\u8d85\u8fc7 60% \u7684 CPU \u4f7f\u7528\uff0c\u5e94\u7528\u7a0b\u5e8f\u4f1a\u88ab\u6740\u6b7b<\/p>\n<h3><span class=\"ez-toc-section\" id=\"19_IO_%E7%9B%91%E6%8E%A7\"><\/span>1.9 IO \u76d1\u63a7<span class=\"ez-toc-section-end\"><\/span><\/h3>\n<p><strong>\u539f\u7406\uff1a<\/strong> Hook \u6587\u4ef6\u8bfb\u5199\u63a5\u53e3\uff0c\u4e3b\u7ebf\u7a0b\u7684 IO \u76d1\u63a7\u53ea\u68c0\u6d4b\u4e3b\u7ebf\u7a0b\u7684 IO\u3002<\/p>\n<p><strong>\u76d1\u63a7\u7b56\u7565\uff1a<\/strong><br \/>\n&#8211; <code>open<\/code> \u4e4b\u540e 30 \u79d2\u6216\u8005 <code>close<\/code> \u7684\u65f6\u5019\u4e0a\u62a5 <code>open<\/code> \u7684\u8c03\u7528\u5806\u6808<br \/>\n&#8211; \u4e0a\u62a5\u5230 Bugly \u7b49\u76d1\u63a7\u5e73\u53f0<\/p>\n<p><strong>\u76d1\u63a7\u63a5\u53e3\uff1a<\/strong><\/p>\n<table>\n<thead>\n<tr>\n<th>\u5e73\u53f0<\/th>\n<th>\u76d1\u63a7\u63a5\u53e3<\/th>\n<\/tr>\n<\/thead>\n<tbody>\n<tr>\n<td>iOS<\/td>\n<td>open, read, write, close<\/td>\n<\/tr>\n<tr>\n<td>Android<\/td>\n<td>open, read, write, close<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<h2><span class=\"ez-toc-section\" id=\"2_%E7%BD%91%E7%BB%9C%E4%BC%98%E5%8C%96\"><\/span>2. \u7f51\u7edc\u4f18\u5316<span class=\"ez-toc-section-end\"><\/span><\/h2>\n<h3><span class=\"ez-toc-section\" id=\"21_%E5%87%8F%E5%B0%91%E7%BD%91%E7%BB%9C%E6%93%8D%E4%BD%9C\"><\/span>2.1 \u51cf\u5c11\u7f51\u7edc\u64cd\u4f5c<span class=\"ez-toc-section-end\"><\/span><\/h3>\n<p>\u7f51\u7edc\u64cd\u4f5c\u662f\u8017\u7535\u5927\u6237\uff0c\u4f18\u5316\u5efa\u8bae\uff1a<\/p>\n<p><strong>\u51cf\u5c11\u6570\u636e\u4f20\u8f93\uff1a<\/strong><br \/>\n&#8211; \u51cf\u5c11\u6570\u636e\u5927\u5c0f<br \/>\n&#8211; \u51cf\u5c11\u5a92\u4f53\u8d28\u91cf\u548c\u5927\u5c0f<br \/>\n&#8211; \u538b\u7f29\u6570\u636e<br \/>\n&#8211; \u907f\u514d\u91cd\u590d\u4f20\u8f93<br \/>\n  &#8211; \u7f13\u5b58\u6570\u636e<br \/>\n  &#8211; \u4f7f\u7528\u53ef\u6682\u505c\u548c\u91cd\u542f\u7684\u4e8b\u52a1<\/p>\n<p><strong>\u9519\u8bef\u5904\u7406\uff1a<\/strong><br \/>\n&#8211; \u68c0\u67e5\u7f51\u7edc\u662f\u5426\u53ef\u7528<br \/>\n&#8211; \u8bbe\u7f6e\u8d85\u65f6<br \/>\n&#8211; \u4f7f\u7528\u91cd\u8bd5\u673a\u5236<\/p>\n<p><strong>\u68c0\u67e5\u7f51\u7edc\u53ef\u7528\u6027\uff1a<\/strong><\/p>\n<pre><code class=\"language-objc\">#import &quot;SystemConfiguration\/SCNetworkReachability.h&quot;\n\n\/\/ \u521b\u5efa\u53ef\u8fbe\u6027\u5bf9\u8c61\nNSString *hostName = @&quot;someHostName&quot;;\nSCNetworkReachabilityRef reachability = SCNetworkReachabilityCreateWithName(\n    NULL, \n    [hostName UTF8String]\n);\n\n\/\/ \u521b\u5efa\u6807\u5fd7\u4f4d\u5b58\u50a8\u7a7a\u95f4\nSCNetworkReachabilityFlags flags;\n\n\/\/ \u68c0\u67e5\u4e3b\u673a\u53ef\u8fbe\u6027\nSCNetworkReachabilityGetFlags(reachability, &amp;flags);\n\n\/\/ \u91ca\u653e\u53ef\u8fbe\u6027\u5bf9\u8c61\nCFRelease(reachability);\n\n\/\/ \u68c0\u67e5\u662f\u5426\u53ef\u8fbe\nif ((flags &amp; kSCNetworkReachabilityFlagsReachable) == 0) {\n    \/\/ \u76ee\u6807\u4e3b\u673a\u4e0d\u53ef\u8fbe\n    \/\/ \u63d0\u793a\u7528\u6237\u6216\u5ef6\u8fdf\u6d3b\u52a8\n}\n<\/code><\/pre>\n<h3><span class=\"ez-toc-section\" id=\"22_%E5%BB%B6%E8%BF%9F%E7%BD%91%E7%BB%9C%E6%93%8D%E4%BD%9C\"><\/span>2.2 \u5ef6\u8fdf\u7f51\u7edc\u64cd\u4f5c<span class=\"ez-toc-section-end\"><\/span><\/h3>\n<p><strong>\u4f18\u5316\u7b56\u7565\uff1a<\/strong><br \/>\n&#8211; \u6279\u91cf\u64cd\u4f5c\uff1a\u5408\u5e76\u591a\u4e2a\u7f51\u7edc\u8bf7\u6c42<br \/>\n&#8211; \u5ef6\u8fdf\u7f51\u7edc\u64cd\u4f5c\uff1a\u975e\u7d27\u6025\u8bf7\u6c42\u5ef6\u8fdf\u6267\u884c<br \/>\n&#8211; \u4f7f\u7528 NSURLSession\uff1a\u72ec\u7acb\u8fdb\u7a0b\uff0c\u4f7f\u7528\u4e8b\u4ef6\u901a\u77e5\uff0c\u9ad8\u6548\u7684\u7f51\u7edc\u64cd\u4f5c\uff0c\u81ea\u6211\u7ea0\u6b63\u9519\u8bef<\/p>\n<p><strong>\u914d\u7f6e\u540e\u53f0\u4f1a\u8bdd\u9009\u9879\uff1a<\/strong><\/p>\n<pre><code class=\"language-objc\">\/\/ \u8bbe\u7f6e\u540e\u53f0\u4f1a\u8bdd\u914d\u7f6e\nNSURLSessionConfiguration *configuration = [NSURLSessionConfiguration \n    backgroundSessionConfigurationWithIdentifier:@&quot;com.&lt;YourApp&gt;.&lt;YourBackgroundSessionIdentifier&gt;&quot;];\n\n\/\/ \u8bbe\u7f6e\u4e3a\u53ef\u5ef6\u8fdf\u6267\u884c\n[configuration setDiscretionary:YES];\n\n\/\/ \u4ec5\u5728 Wi-Fi \u4e0b\u6267\u884c\nconfiguration.allowsCellularAccess = NO;\n\n\/\/ \u8bbe\u7f6e\u5728\u63a5\u4e0b\u6765\u7684 18 \u5c0f\u65f6\u5185\u6267\u884c\n[configuration setTimeoutIntervalForResource:18 * 60 * 60];\n\n\/\/ \u521b\u5efa URL \u4f1a\u8bdd\nNSURLSession *backgroundSession = [NSURLSession sessionWithConfiguration:configuration \n    delegate:self \n    delegateQueue:nil];\n\n\/\/ \u8bbe\u7f6e URL\nNSURL *someURLToDownload = [NSURL URLWithString:&lt;YourURLString&gt;];\n\n\/\/ \u521b\u5efa URL \u8bf7\u6c42\nNSURLRequest *downloadRequest = [NSURLRequest requestWithURL:someURLToDownload];\n\n\/\/ \u6dfb\u52a0\u5230\u540e\u53f0\u4f1a\u8bdd\nNSURLSessionDownloadTask *downloadTask = [backgroundSession downloadTaskWithRequest:downloadRequest];\n\n\/\/ \u542f\u52a8\u4efb\u52a1\n[downloadTask resume];\n<\/code><\/pre>\n<p><strong>\u63a5\u6536\u4e0b\u8f7d\u5b8c\u6210\u901a\u77e5\uff1a<\/strong><\/p>\n<pre><code class=\"language-objc\">- (void)URLSession:(NSURLSession *)session \n    downloadTask:(NSURLSessionDownloadTask *)downloadTask \n    didFinishDownloadingToURL:(NSURL *)location {\n    \/\/ \u5904\u7406\u4e0b\u8f7d\u5b8c\u6210\u540e\u7684\u5de5\u4f5c\n}\n<\/code><\/pre>\n<h2><span class=\"ez-toc-section\" id=\"3_%E5%9B%BE%E5%BD%A2%E3%80%81%E5%8A%A8%E7%94%BB%E5%92%8C%E8%A7%86%E9%A2%91%E4%BC%98%E5%8C%96\"><\/span>3. \u56fe\u5f62\u3001\u52a8\u753b\u548c\u89c6\u9891\u4f18\u5316<span class=\"ez-toc-section-end\"><\/span><\/h2>\n<h3><span class=\"ez-toc-section\" id=\"31_%E9%81%BF%E5%85%8D%E8%BF%87%E5%BA%A6%E7%9A%84%E5%9B%BE%E5%BD%A2%E5%92%8C%E5%8A%A8%E7%94%BB\"><\/span>3.1 \u907f\u514d\u8fc7\u5ea6\u7684\u56fe\u5f62\u548c\u52a8\u753b<span class=\"ez-toc-section-end\"><\/span><\/h3>\n<p>\u56fe\u5f62\u6e32\u67d3\u548c\u52a8\u753b\u4f1a\u6d88\u8017\u5927\u91cf\u7535\u91cf\uff0c\u4f18\u5316\u5efa\u8bae\uff1a<\/p>\n<ul>\n<li>\u51cf\u5c11\u89c6\u56fe\u7684\u6570\u91cf<\/li>\n<li>\u51cf\u5c11\u900f\u660e\u5ea6\u7684\u4f7f\u7528<\/li>\n<li>\u900f\u660e\u89c6\u56fe\u76d6\u5728\u9891\u7e41\u5237\u65b0\u5185\u5bb9\u7684\u89c6\u56fe\u4e0a\u9762\u4f1a\u589e\u52a0\u6e32\u67d3\u8d1f\u62c5<\/li>\n<li>\u907f\u514d\u7ed8\u5236\u4e0d\u53ef\u89c1\u7684\u5185\u5bb9<\/li>\n<li>\u4f7f\u7528\u4f4e\u5e27\u7387\u52a8\u753b<\/li>\n<li>\u52a8\u753b\u4f7f\u7528\u4e00\u81f4\u7684\u5e27\u7387<\/li>\n<li>\u907f\u514d\u5c4f\u5e55\u4e0a\u540c\u65f6\u6709\u591a\u79cd\u4e0d\u540c\u7684\u5e27\u7387<\/li>\n<li>\u6e38\u620f\u5f00\u53d1\u4f7f\u7528\u63a8\u8350\u7684\u6846\u67b6<\/li>\n<\/ul>\n<h3><span class=\"ez-toc-section\" id=\"32_%E6%92%AD%E6%94%BE%E5%85%A8%E5%B1%8F%E8%A7%86%E9%A2%91%E6%97%B6%E7%9A%84%E4%BC%98%E5%8C%96\"><\/span>3.2 \u64ad\u653e\u5168\u5c4f\u89c6\u9891\u65f6\u7684\u4f18\u5316<span class=\"ez-toc-section-end\"><\/span><\/h3>\n<p>\u64ad\u653e\u5168\u5c4f\u89c6\u9891\u65f6\uff0c\u907f\u514d\u663e\u793a\u5176\u4ed6 UI \u5143\u7d20\uff0c\u51cf\u5c11\u4e0d\u5fc5\u8981\u7684\u6e32\u67d3\u3002<\/p>\n<h2><span class=\"ez-toc-section\" id=\"4_%E4%BD%8D%E7%BD%AE%E5%92%8C%E4%BC%A0%E6%84%9F%E5%99%A8%E4%BC%98%E5%8C%96\"><\/span>4. \u4f4d\u7f6e\u548c\u4f20\u611f\u5668\u4f18\u5316<span class=\"ez-toc-section-end\"><\/span><\/h2>\n<h3><span class=\"ez-toc-section\" id=\"41_%E5%87%8F%E5%B0%91%E4%BD%8D%E7%BD%AE%E7%B2%BE%E5%BA%A6%E5%92%8C%E6%8C%81%E7%BB%AD%E6%97%B6%E9%97%B4\"><\/span>4.1 \u51cf\u5c11\u4f4d\u7f6e\u7cbe\u5ea6\u548c\u6301\u7eed\u65f6\u95f4<span class=\"ez-toc-section-end\"><\/span><\/h3>\n<p>\u4f4d\u7f6e\u670d\u52a1\u662f\u8017\u7535\u5927\u6237\uff0c\u4f18\u5316\u5efa\u8bae\uff1a<\/p>\n<ul>\n<li>\u505c\u6b62\u4f4d\u7f6e\u670d\u52a1\uff1a\u4e0d\u9700\u8981\u65f6\u53ca\u65f6\u505c\u6b62<\/li>\n<li>\u964d\u4f4e\u8bf7\u6c42\u7684\u4f4d\u7f6e\u7cbe\u5ea6\uff1a\u4f7f\u7528\u8f83\u4f4e\u7684\u7cbe\u5ea6\u8981\u6c42<\/li>\n<li>\u505c\u6b62\u66f4\u65b0\uff1a\u5982\u679c\u4f4d\u7f6e\u7cbe\u5ea6\u4e0d\u7b26\u5408\u9884\u671f\uff0c\u505c\u6b62\u66f4\u65b0<\/li>\n<li>\u4f7f\u7528\u8bbf\u95ee\u76d1\u63a7\uff1a\u4f7f\u7528 <code>CLVisit<\/code> \u76d1\u63a7\u4f4d\u7f6e\u8bbf\u95ee<\/li>\n<li>\u6700\u540e\u624d\u4f7f\u7528\u663e\u8457\u4f4d\u7f6e\u66f4\u65b0\uff1a\u4f18\u5148\u4f7f\u7528\u5176\u4ed6\u4f4e\u529f\u8017\u65b9\u6848<\/li>\n<\/ul>\n<p><strong>\u5feb\u901f\u4f4d\u7f6e\u66f4\u65b0\u793a\u4f8b\uff1a<\/strong><\/p>\n<pre><code class=\"language-objc\">- (void)viewDidLoad {\n    \/\/ \u521b\u5efa\u4f4d\u7f6e\u7ba1\u7406\u5668\u5bf9\u8c61\n    self.locationManager = [[CLLocationManager alloc] init];\n\n    \/\/ \u8bbe\u7f6e\u4ee3\u7406\n    self.locationManager.delegate = self;\n}\n\n- (void)getQuickLocationUpdate {\n    \/\/ \u8bf7\u6c42\u4f4d\u7f6e\u6388\u6743\n    [self.locationManager requestWhenInUseAuthorization];\n\n    \/\/ \u8bf7\u6c42\u4f4d\u7f6e\u66f4\u65b0\n    [self.locationManager requestLocation];\n    \/\/ \u6ce8\u610f\uff1a\u5982\u679c\u6388\u6743\u5c1a\u672a\u6388\u4e88\uff0crequestLocation \u53ef\u80fd\u4f1a\u8d85\u65f6\u5e76\u4ea7\u751f\u9519\u8bef\n\n    \/\/ \u8bbe\u7f6e\u7cbe\u5ea6\u7ea7\u522b\uff0c\u7cbe\u5ea6\u8d8a\u9ad8\uff0c\u529f\u8017\u8d8a\u5927\n    self.locationManager.desiredAccuracy = kCLLocationAccuracyThreeKilometers;\n\n    \/\/ \u542f\u7528\u81ea\u52a8\u6682\u505c\n    self.locationManager.pausesLocationUpdatesAutomatically = YES;\n\n    \/\/ \u6307\u5b9a\u5e94\u7528\u5f53\u524d\u6267\u884c\u7684\u6d3b\u52a8\u7c7b\u578b\n    self.locationManager.activityType = CLActivityTypeFitness;\n\n    \/\/ \u542f\u7528\u540e\u53f0\u4f4d\u7f6e\u66f4\u65b0\n    self.locationManager.allowsBackgroundLocationUpdates = YES;\n\n    \/\/ \u5f00\u59cb\u4f4d\u7f6e\u66f4\u65b0\n    [self.locationManager startUpdatingLocation];\n}\n\n- (void)locationManager:(CLLocationManager *)manager \n    didUpdateLocations:(NSArray *)locations {\n    \/\/ \u5904\u7406\u63a5\u6536\u5230\u7684\u4f4d\u7f6e\u66f4\u65b0\n    [self.locationManager stopUpdatingLocation];\n}\n<\/code><\/pre>\n<p><strong>\u5ef6\u8fdf\u4f4d\u7f6e\u66f4\u65b0\u793a\u4f8b\uff1a<\/strong><\/p>\n<pre><code class=\"language-objc\">- (void)locationManager:(CLLocationManager *)manager \n    didUpdateLocations:(NSArray *)locations {\n    \/\/ \u6dfb\u52a0\u65b0\u4f4d\u7f6e\u5230\u884c\u7a0b\n    [self.hike addLocations:locations];\n\n    \/\/ \u5ef6\u8fdf\u66f4\u65b0\u76f4\u5230\u7528\u6237\u79fb\u52a8\u4e00\u5b9a\u8ddd\u79bb\u6216\u7ecf\u8fc7\u4e00\u6bb5\u65f6\u95f4\n    if (!self.deferringUpdates) {\n        CLLocationDistance distance = self.hike.goal - self.hike.distance;\n        NSTimeInterval time = [self.nextUpdate timeIntervalSinceNow];\n        [self.locationManager allowDeferredLocationUpdatesUntilTraveled:distance \n            timeout:time];\n        self.deferringUpdates = YES;\n    }\n}\n\n- (void)locationManager:(CLLocationManager *)manager \n    didFinishDeferredUpdatesWithError:(NSError *)error {\n    \/\/ \u505c\u6b62\u5ef6\u8fdf\u66f4\u65b0\n    self.deferringUpdates = NO;\n\n    \/\/ \u8c03\u6574\u4e0b\u4e00\u4e2a\u76ee\u6807\n}\n<\/code><\/pre>\n<p><strong>\u4f7f\u7528\u8bbf\u95ee\u76d1\u63a7\uff1a<\/strong><\/p>\n<pre><code class=\"language-objc\">- (void)startVisitMonitoring {\n    \/\/ \u521b\u5efa\u4f4d\u7f6e\u7ba1\u7406\u5668\u5bf9\u8c61\n    self.locationManager = [[CLLocationManager alloc] init];\n\n    \/\/ \u8bbe\u7f6e\u4ee3\u7406\n    self.locationManager.delegate = self;\n\n    \/\/ \u8bf7\u6c42\u4f4d\u7f6e\u6388\u6743\n    [self.locationManager requestAlwaysAuthorization];\n\n    \/\/ \u5f00\u59cb\u76d1\u63a7\u8bbf\u95ee\n    [self.locationManager startMonitoringVisits];\n}\n\n- (void)stopVisitMonitoring {\n    [self.locationManager stopMonitoringVisits];\n}\n\n- (void)locationManager:(CLLocationManager *)manager \n    didVisit:(CLVisit *)visit {\n    \/\/ \u6267\u884c\u57fa\u4e8e\u4f4d\u7f6e\u7684\u6d3b\u52a8\n    \/\/ ...\n}\n<\/code><\/pre>\n<p><strong>\u663e\u8457\u4f4d\u7f6e\u66f4\u65b0\uff1a<\/strong><\/p>\n<pre><code class=\"language-objc\">- (void)startSignificantChangeLocationUpdates {\n    \/\/ \u521b\u5efa\u4f4d\u7f6e\u7ba1\u7406\u5668\u5bf9\u8c61\n    self.locationManager = [[CLLocationManager alloc] init];\n\n    \/\/ \u8bbe\u7f6e\u4ee3\u7406\n    self.locationManager.delegate = self;\n\n    \/\/ \u8bf7\u6c42\u4f4d\u7f6e\u6388\u6743\n    [self.locationManager requestAlwaysAuthorization];\n\n    \/\/ \u5f00\u59cb\u663e\u8457\u4f4d\u7f6e\u66f4\u65b0\n    [self.locationManager startMonitoringSignificantLocationChanges];\n}\n\n- (void)locationManager:(CLLocationManager *)manager \n    didUpdateLocations:(NSArray *)locations {\n    \/\/ \u6267\u884c\u57fa\u4e8e\u4f4d\u7f6e\u7684\u6d3b\u52a8\n    \/\/ ...\n\n    \/\/ \u4e0d\u518d\u9700\u8981\u65f6\u505c\u6b62\u663e\u8457\u4f4d\u7f6e\u66f4\u65b0\n    [self.locationManager stopMonitoringSignificantLocationChanges];\n}\n<\/code><\/pre>\n<h3><span class=\"ez-toc-section\" id=\"42_%E5%87%8F%E5%B0%91%E4%BC%A0%E6%84%9F%E5%99%A8%E6%9B%B4%E6%96%B0%E9%A2%91%E7%8E%87\"><\/span>4.2 \u51cf\u5c11\u4f20\u611f\u5668\u66f4\u65b0\u9891\u7387<span class=\"ez-toc-section-end\"><\/span><\/h3>\n<p>\u4f20\u611f\u5668\u66f4\u65b0\u4f1a\u6d88\u8017\u7535\u91cf\uff0c\u4f18\u5316\u5efa\u8bae\uff1a<\/p>\n<ul>\n<li>\u4e0d\u9700\u8981\u65f6\u505c\u6b62\u63a5\u6536\u65b9\u5411\u6539\u53d8\u901a\u77e5<\/li>\n<li>\u8bf7\u6c42\u4f4e\u9891\u7387\u7684\u4f20\u611f\u5668\u66f4\u65b0<\/li>\n<\/ul>\n<p><strong>\u8bbe\u5907\u65b9\u5411\u901a\u77e5\uff1a<\/strong><\/p>\n<pre><code class=\"language-objc\">- (void)viewDidLoad {\n    \/\/ \u5f00\u542f\u52a0\u901f\u5ea6\u8ba1\n    [[UIDevice currentDevice] beginGeneratingDeviceOrientationNotifications];\n\n    \/\/ \u6ce8\u518c\u65b9\u5411\u6539\u53d8\u901a\u77e5\n    [[NSNotificationCenter defaultCenter] addObserver:self \n        selector:@selector(orientationChanged:) \n        name:UIDeviceOrientationDidChangeNotification \n        object:nil];\n}\n\n- (void)orientationChanged:(NSNotification *)notification {\n    \/\/ \u54cd\u5e94\u65b9\u5411\u6539\u53d8\n}\n\n- (void)viewDidDisappear:(BOOL)animated {\n    \/\/ \u505c\u6b62\u63a5\u6536\u65b9\u5411\u6539\u53d8\u901a\u77e5\n    [[NSNotificationCenter defaultCenter] removeObserver:self];\n\n    \/\/ \u5173\u95ed\u52a0\u901f\u5ea6\u8ba1\n    [[UIDevice currentDevice] endGeneratingDeviceOrientationNotifications];\n}\n<\/code><\/pre>\n<p><strong>\u52a0\u901f\u5ea6\u8ba1\u66f4\u65b0\uff1a<\/strong><\/p>\n<pre><code class=\"language-objc\">- (void)viewDidLoad {\n    [super viewDidLoad];\n\n    \/\/ \u521b\u5efa Core Motion \u7ba1\u7406\u5668\u5bf9\u8c61\n    self.motionManager = [[CMMotionManager alloc] init];\n}\n\n- (void)startAccelerometerUpdates {\n    \/\/ \u68c0\u67e5\u52a0\u901f\u5ea6\u8ba1\u662f\u5426\u53ef\u7528\n    if ([self.motionManager isAccelerometerAvailable] == YES) {\n        \/\/ \u66f4\u65b0\u66f4\u65b0\u95f4\u9694\n        [self.motionManager setAccelerometerUpdateInterval:updateInterval];\n\n        \/\/ \u5f00\u59cb\u52a0\u901f\u5ea6\u8ba1\u66f4\u65b0\n        [self.motionManager startAccelerometerUpdatesToQueue:[NSOperationQueue mainQueue] \n            withHandler:^(CMAccelerometerData *accelerometerData, NSError *error) {\n                \/\/ \u5904\u7406\u52a0\u901f\u5ea6\u8ba1\u6570\u636e\n            }];\n    }\n}\n\n- (void)stopUpdates {\n    \/\/ \u68c0\u67e5\u52a0\u901f\u5ea6\u8ba1\u662f\u5426\u6d3b\u8dc3\n    if ([self.motionManager isAccelerometerActive] == YES) {\n        \/\/ \u505c\u6b62\u52a0\u901f\u5ea6\u8ba1\u66f4\u65b0\n        [self.motionManager stopAccelerometerUpdates];\n    }\n}\n<\/code><\/pre>\n<h2><span class=\"ez-toc-section\" id=\"5_%E9%80%9A%E7%9F%A5%E4%BC%98%E5%8C%96\"><\/span>5. \u901a\u77e5\u4f18\u5316<span class=\"ez-toc-section-end\"><\/span><\/h2>\n<ul>\n<li>\u5c3d\u91cf\u4f7f\u7528\u672c\u5730\u901a\u77e5\uff1a\u672c\u5730\u901a\u77e5\u6bd4\u8fdc\u7a0b\u901a\u77e5\u66f4\u7701\u7535<\/li>\n<li>\u533a\u5206\u8fdc\u7a0b\u901a\u77e5\u7684\u4f18\u5148\u7ea7\uff1a\u6839\u636e\u91cd\u8981\u6027\u8bbe\u7f6e\u4e0d\u540c\u7684\u4f18\u5148\u7ea7<\/li>\n<\/ul>\n<h2><span class=\"ez-toc-section\" id=\"6_%E5%87%8F%E5%B0%91%E5%A4%96%E9%83%A8%E8%AE%BE%E5%A4%87%E4%BA%A4%E4%BA%92\"><\/span>6. \u51cf\u5c11\u5916\u90e8\u8bbe\u5907\u4ea4\u4e92<span class=\"ez-toc-section-end\"><\/span><\/h2>\n<h3><span class=\"ez-toc-section\" id=\"61_%E8%93%9D%E7%89%99%E6%9C%80%E4%BD%B3%E5%AE%9E%E8%B7%B5\"><\/span>6.1 \u84dd\u7259\u6700\u4f73\u5b9e\u8df5<span class=\"ez-toc-section-end\"><\/span><\/h3>\n<p>\u84dd\u7259\u901a\u4fe1\u4f1a\u6d88\u8017\u5927\u91cf\u7535\u91cf\uff0c\u4f18\u5316\u5efa\u8bae\uff1a<\/p>\n<p><strong>\u626b\u63cf\u8bbe\u5907\uff1a<\/strong><br \/>\n&#8211; \u53ea\u6709\u9700\u8981\u65f6\u624d\u626b\u63cf\u8bbe\u5907<br \/>\n&#8211; \u6700\u5c0f\u5316\u5904\u7406\u91cd\u590d\u8bbe\u5907\u53d1\u73b0\u6d88\u606f\uff1a<code>scanForPeripheralsWithServices:options:<\/code> \u65b9\u6cd5\u4e0d\u8981\u8bbe\u7f6e <code>CBCentralManagerScanOptionAllowDuplicatesKey<\/code> \u9009\u9879<br \/>\n&#8211; \u53ea\u53d1\u73b0\u9700\u8981\u7684\u670d\u52a1\u548c\u7279\u6027<br \/>\n&#8211; \u4f7f\u7528\u901a\u77e5\u800c\u4e0d\u662f\u8f6e\u8be2\u53bb\u53d1\u73b0\u7279\u6027\u7684\u53d8\u5316<br \/>\n&#8211; \u4e0d\u9700\u8981\u65f6\u65ad\u5f00\u8bbe\u5907<\/p>\n<p><strong>\u626b\u63cf\u8bbe\u5907\u793a\u4f8b\uff1a<\/strong><\/p>\n<pre><code class=\"language-objc\">- (void)beginScanningForDevice {\n    \/\/ \u521b\u5efa Core Bluetooth \u4e2d\u592e\u7ba1\u7406\u5668\u5bf9\u8c61\n    self.myCentralManager = [[CBCentralManager alloc] initWithDelegate:self \n        queue:nil \n        options:nil];\n\n    \/\/ \u626b\u63cf\u5916\u8bbe\n    [self.myCentralManager scanForPeripheralsWithServices:nil options:nil];\n}\n\n- (void)centralManager:(CBCentralManager *)central \n    didDiscoverPeripheral:(CBPeripheral *)peripheral \n    advertisementData:(NSDictionary *)advertisementData \n    RSSI:(NSNumber *)RSSI {\n    \/\/ \u8fde\u63a5\u5230\u65b0\u53d1\u73b0\u7684\u8bbe\u5907\n    \/\/ ...\n\n    \/\/ \u505c\u6b62\u626b\u63cf\u8bbe\u5907\n    [self.myCentralManager stopScan];\n}\n<\/code><\/pre>\n<p><strong>\u53d1\u73b0\u670d\u52a1\u548c\u7279\u6027\uff1a<\/strong><\/p>\n<pre><code class=\"language-objc\">\/\/ \u67e5\u627e\u5339\u914d\u7279\u5b9a UUID \u96c6\u5408\u7684\u670d\u52a1\n[peripheral discoverServices:@[firstServiceUUID, secondServiceUUID]];\n\n\/\/ \u67e5\u627e\u7ed9\u5b9a\u670d\u52a1\u4e2d\u5339\u914d\u7279\u5b9a UUID \u96c6\u5408\u7684\u7279\u6027\n[peripheral discoverCharacteristics:@[firstCharacteristicUUID, secondCharacteristicUUID] \n    forService:interestingService];\n<\/code><\/pre>\n<p><strong>\u8ba2\u9605\u7279\u6027\u503c\uff1a<\/strong><\/p>\n<pre><code class=\"language-objc\">- (void)subscribeToCharacteristic {\n    \/\/ \u8ba2\u9605\u7279\u6027\u503c\n    [self.peripheral setNotifyValue:YES forCharacteristic:interestingCharacteristic];\n}\n\n- (void)peripheral:(CBPeripheral *)peripheral \n    didUpdateNotificationStateForCharacteristic:(CBCharacteristic *)characteristic \n    error:(NSError *)error {\n    \/\/ \u5904\u7406\u7279\u6027\u503c\u66f4\u65b0\n}\n\n\/\/ \u4e0d\u9700\u8981\u65f6\u65ad\u5f00\u8bbe\u5907\n\/\/ \u53d6\u6d88\u8ba2\u9605\u7279\u6027\u503c\n[self.peripheral setNotifyValue:NO forCharacteristic:interestingCharacteristic];\n\n\/\/ \u65ad\u5f00\u8bbe\u5907\u8fde\u63a5\n[self.myCentralManager cancelPeripheralConnection:peripheral];\n<\/code><\/pre>\n<h2><span class=\"ez-toc-section\" id=\"7_%E8%83%BD%E8%80%97%E7%9B%91%E6%8E%A7\"><\/span>7. \u80fd\u8017\u76d1\u63a7<span class=\"ez-toc-section-end\"><\/span><\/h2>\n<h3><span class=\"ez-toc-section\" id=\"71_%E8%83%BD%E8%80%97%E8%BF%87%E5%BA%A6%E4%BD%BF%E7%94%A8%E7%9A%84%E4%BF%A1%E5%8F%B7\"><\/span>7.1 \u80fd\u8017\u8fc7\u5ea6\u4f7f\u7528\u7684\u4fe1\u53f7<span class=\"ez-toc-section-end\"><\/span><\/h3>\n<p>\u4ee5\u4e0b\u4fe1\u53f7\u53ef\u80fd\u8868\u660e\u5e94\u7528\u80fd\u8017\u8fc7\u9ad8\uff1a<\/p>\n<ul>\n<li>\u7535\u6c60\u8017\u7aed\uff1a\u8bbe\u5907\u7535\u91cf\u5feb\u901f\u4e0b\u964d<\/li>\n<li>\u671f\u5f85\u5e94\u7528\u7a7a\u95f2\u72b6\u6001\uff0c\u4f46\u8fd8\u662f\u5904\u4e8e\u6d3b\u8dc3\u72b6\u6001<\/li>\n<li>\u6ca1\u6709\u54cd\u5e94\u6216\u8005\u5f88\u6162\u7684\u7528\u6237\u63a5\u53e3<\/li>\n<li>\u4e3b\u7ebf\u7a0b\u5b58\u5728\u5927\u91cf\u7684\u4efb\u52a1<\/li>\n<li>\u5927\u91cf\u4f7f\u7528\u52a8\u753b<\/li>\n<li>\u5927\u91cf\u4f7f\u7528\u900f\u660e\u5ea6<\/li>\n<li>\u5185\u5b58\u4ea4\u6362\uff1a\u5185\u5b58\u548c\u7f13\u5b58\u5931\u6548\uff0c\u5185\u5b58\u544a\u8b66<\/li>\n<li>\u9501\u7ade\u4e89\uff1a\u7ebf\u7a0b\u95f4\u7ade\u4e89\u6fc0\u70c8<\/li>\n<li>\u8fc7\u5ea6\u7684\u4e0a\u4e0b\u6587\u5207\u6362<\/li>\n<li>\u8fc7\u5ea6\u4f7f\u7528\u5b9a\u65f6\u5668<\/li>\n<li>\u8fc7\u5ea6\u7684\u5c4f\u5e55\u7ed8\u5236<\/li>\n<li>\u8fc7\u5ea6\u6216\u8005\u91cd\u590d\u7684\u5c11\u91cf IO<\/li>\n<li>\u9ad8\u8d1f\u8f7d\u7684\u901a\u4fe1<\/li>\n<li>\u8bbe\u5907\u65e0\u6cd5\u8fdb\u5165\u4f11\u7720\u72b6\u6001<\/li>\n<\/ul>\n<h3><span class=\"ez-toc-section\" id=\"72_%E7%9B%91%E6%8E%A7%E6%96%B9%E6%B3%95\"><\/span>7.2 \u76d1\u63a7\u65b9\u6cd5<span class=\"ez-toc-section-end\"><\/span><\/h3>\n<p><strong>\u65b9\u6cd5 1\uff1a\u624b\u673a\u8bbe\u7f6e -&gt; \u7535\u6c60<\/strong><\/p>\n<ul>\n<li><strong>\u663e\u793a\u7535\u6c60\u7528\u91cf<\/strong>\uff1a4 \u683c\u8868\u793a\u4e00\u4e2a\u5c0f\u65f6\uff0c\u53ea\u80fd\u901a\u8fc7\u56fe\u5f62\u6bd4\u4f8b\u53bb\u8ba1\u7b97\u8017\u7535\u91cf<\/li>\n<li><strong>\u663e\u793a\u6d3b\u52a8<\/strong>\uff1a\u53ef\u4ee5\u770b\u5230 App \u7684\u6d3b\u52a8\u65f6\u95f4\uff0c\u5305\u62ec\u524d\u540e\u53f0\u65f6\u95f4<\/li>\n<\/ul>\n<p><img decoding=\"async\" alt=\"\u7535\u6c60\u7528\u91cf\" src=\"https:\/\/www.ixriver.com\/wp-content\/uploads\/2026\/02\/image_2-2.png\" \/><\/p>\n<p><img decoding=\"async\" alt=\"\u6d3b\u52a8\u65f6\u95f4\" src=\"https:\/\/www.ixriver.com\/wp-content\/uploads\/2026\/02\/image_3-2.png\" \/><\/p>\n<p><strong>\u65b9\u6cd5 2\uff1a\u8c03\u8bd5\u4eea\u8868\u76d8 Xcode -&gt; Energy Impact<\/strong><\/p>\n<p>\u53ef\u4ee5\u663e\u793a\u5404\u4e2a\u7ec4\u4ef6\u7684\u80fd\u8017\u5206\u5e03\u5360\u6bd4\u3002<\/p>\n<p><img decoding=\"async\" alt=\"Energy Impact\" src=\"https:\/\/www.ixriver.com\/wp-content\/uploads\/2026\/02\/image_4-2.png\" \/><\/p>\n<p><strong>\u65b9\u6cd5 3\uff1a\u8bbe\u7f6e -&gt; \u5f00\u53d1\u8005\u9009\u9879 -&gt; Logging -&gt; Energy\uff08\u65b0\u7248\u672c\u5df2\u7ecf\u6ca1\u6709\u8fd9\u4e2a\u9009\u9879\uff09<\/strong><\/p>\n<p>\u65e5\u5fd7\u5bfc\u51fa\u65b9\u6cd5\uff1aInstruments -&gt; Energy Log -&gt; Import Logged Data From Device<\/p>\n<p><strong>\u65b9\u6cd5 4\uff1aInstruments -&gt; Energy Log\uff08\u65b0\u7248\u672c\u5df2\u7ecf\u6ca1\u6709\u8fd9\u4e2a\u9009\u9879\uff09<\/strong><\/p>\n<h2><span class=\"ez-toc-section\" id=\"8_%E4%BC%98%E5%8C%96%E5%BB%BA%E8%AE%AE\"><\/span>8. \u4f18\u5316\u5efa\u8bae<span class=\"ez-toc-section-end\"><\/span><\/h2>\n<h3><span class=\"ez-toc-section\" id=\"81_%E6%80%A7%E8%83%BD%E4%BC%98%E5%8C%96\"><\/span>8.1 \u6027\u80fd\u4f18\u5316<span class=\"ez-toc-section-end\"><\/span><\/h3>\n<ul>\n<li><strong>\u964d\u9891\u548c\u964d\u538b<\/strong>\uff1a\u964d\u9891\u548c\u964d\u538b\u76f4\u63a5\u548c\u529f\u8017\u76f8\u5173\uff0c\u5e94\u7528\u4e0d\u9700\u8981\u90a3\u4e48\u9ad8\u7684 CPU<\/li>\n<li><strong>\u5904\u7406\u5668\u5dee\u5f02<\/strong>\uff1a\u540c\u79cd\u5904\u7406\u5668\uff0c\u4e0d\u540c\u624b\u673a\u7684\u964d\u9891\u7b56\u7565\u662f\u4e0d\u4e00\u6837\u7684<\/li>\n<\/ul>\n<h3><span class=\"ez-toc-section\" id=\"82_%E4%BB%A3%E7%A0%81%E4%BC%98%E5%8C%96\"><\/span>8.2 \u4ee3\u7801\u4f18\u5316<span class=\"ez-toc-section-end\"><\/span><\/h3>\n<ul>\n<li><strong>\u907f\u514d\u4f7f\u7528 NSDateFormatter<\/strong>\uff1aNSDateFormatter \u521b\u5efa\u548c\u89e3\u6790\u5f00\u9500\u8f83\u5927<\/li>\n<li><strong>\u5c11\u7528\u8fd0\u7b97\u83b7\u5f97\u5706\u89d2<\/strong>\uff1a\u4f7f\u7528 <code>CALayer<\/code> \u7684 <code>cornerRadius<\/code> \u5c5e\u6027\uff0c\u907f\u514d\u4f7f\u7528 <code>UIBezierPath<\/code> \u7ed8\u5236\u5706\u89d2<\/li>\n<li><strong>\u907f\u514d\u5e9e\u5927\u7684 xib<\/strong>\uff1axib \u6587\u4ef6\u8fc7\u5927\u4f1a\u5f71\u54cd\u52a0\u8f7d\u548c\u6e32\u67d3\u6027\u80fd<\/li>\n<\/ul>\n<h3><span class=\"ez-toc-section\" id=\"83_%E8%83%BD%E8%80%97%E8%B0%83%E8%AF%95%E6%96%B0%E7%89%B9%E6%80%A7\"><\/span>8.3 \u80fd\u8017\u8c03\u8bd5\u65b0\u7279\u6027<span class=\"ez-toc-section-end\"><\/span><\/h3>\n<ul>\n<li>\u76d1\u63a7\u624b\u673a\u7684\u4f4e\u7535\u91cf\u6a21\u5f0f<\/li>\n<li>\u76d1\u63a7\u624b\u673a\u7684\u53d1\u70ed\u72b6\u6001<\/li>\n<\/ul>\n<h2><span class=\"ez-toc-section\" id=\"9_%E5%85%B6%E4%BB%96\"><\/span>9. \u5176\u4ed6<span class=\"ez-toc-section-end\"><\/span><\/h2>\n<h3><span class=\"ez-toc-section\" id=\"91_iOS_%E5%90%8E%E5%8F%B0%E7%A8%8B%E5%BA%8F\"><\/span>9.1 iOS \u540e\u53f0\u7a0b\u5e8f<span class=\"ez-toc-section-end\"><\/span><\/h3>\n<p>iOS \u7cfb\u7edf\u540e\u53f0\u8fdb\u7a0b\u53ca\u5176\u529f\u8017\u5360\u6bd4\uff1a<\/p>\n<table>\n<thead>\n<tr>\n<th>\u8fdb\u7a0b<\/th>\n<th>\u529f\u8017\u5360\u6bd4<\/th>\n<th>\u63cf\u8ff0<\/th>\n<\/tr>\n<\/thead>\n<tbody>\n<tr>\n<td>backboardd<\/td>\n<td>7.4%<\/td>\n<td>\u5904\u7406\u8f93\u5165\u548c\u8fdb\u7a0b\u7ba1\u7406<\/td>\n<\/tr>\n<tr>\n<td>DTServiceHub<\/td>\n<td>4.1%<\/td>\n<td>\u5f00\u53d1\u5de5\u5177\u670d\u52a1<\/td>\n<\/tr>\n<tr>\n<td>mediaserverd<\/td>\n<td>17.0%<\/td>\n<td>\u63d0\u4f9b\u97f3\u89c6\u9891\u529f\u80fd<\/td>\n<\/tr>\n<tr>\n<td>sysmond<\/td>\n<td>17.4%<\/td>\n<td>\u7cfb\u7edf\u76d1\u63a7\u8fdb\u7a0b<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<h2><span class=\"ez-toc-section\" id=\"%E5%8F%82%E8%80%83%E8%B5%84%E6%96%99\"><\/span>\u53c2\u8003\u8d44\u6599<span class=\"ez-toc-section-end\"><\/span><\/h2>\n<ul>\n<li>\u300aiOS \u7535\u91cf\u68c0\u6d4b\u548c\u4f18\u5316\u300b<\/li>\n<\/ul>\n","protected":false},"excerpt":{"rendered":"<p>iOS \u7535\u91cf\u4f18\u5316 1. CPU \u4f18\u5316 1.1 CPU \u4f7f\u7528\u7387\u4e0e\u529f\u8017 CPU \u4f7f\u7528\u7387\u4e0e\u529f\u8017\u6210\u6b63\u6bd4\u5173\u7cfb\u3002CPU \u4f7f [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[36],"tags":[],"blocksy_meta":[],"featured_image_urls":{"full":"","thumbnail":"","medium":"","medium_large":"","large":"","1536x1536":"","2048x2048":""},"post_excerpt_stackable":"<p>\u76ee\u5f55 Toggle iOS \u7535\u91cf\u4f18\u53161. CPU \u4f18\u53161.1 CPU \u4f7f\u7528\u7387\u4e0e\u529f\u80171.2 \u540e\u53f0\u4efb\u52a1\u4f18\u53161.3 \u8c03\u6574\u4efb\u52a1\u7684 QoS \u7ea7\u522b1.4 \u51cf\u5c11\u5b9a\u65f6\u5668\u7684\u4f7f\u75281.5 \u51cf\u5c11 IO \u64cd\u4f5c1.6 \u5904\u7406\u4f4e\u7535\u91cf&hellip;<\/p>\n","category_list":"<a href=\"https:\/\/p.ixriver.com\/?cat=36\" rel=\"category\">\u6027\u80fd\u4f18\u5316<\/a>","author_info":{"name":"admin","url":"https:\/\/p.ixriver.com\/?author=1"},"comments_num":"0 comments","_links":{"self":[{"href":"https:\/\/p.ixriver.com\/index.php?rest_route=\/wp\/v2\/posts\/873"}],"collection":[{"href":"https:\/\/p.ixriver.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/p.ixriver.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/p.ixriver.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/p.ixriver.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=873"}],"version-history":[{"count":0,"href":"https:\/\/p.ixriver.com\/index.php?rest_route=\/wp\/v2\/posts\/873\/revisions"}],"wp:attachment":[{"href":"https:\/\/p.ixriver.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=873"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/p.ixriver.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=873"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/p.ixriver.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=873"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}