{"id":4538,"date":"2017-04-05T22:01:00","date_gmt":"2017-04-05T14:01:00","guid":{"rendered":"http:\/\/blog.qdac.cc\/?p=4538"},"modified":"2017-04-05T22:01:00","modified_gmt":"2017-04-05T14:01:00","slug":"%e6%9d%82%e8%b0%88objective-c%e5%af%b9%e8%b1%a1%e7%9a%84%e7%94%9f%e5%91%bd%e5%91%a8%e6%9c%9f","status":"publish","type":"post","link":"https:\/\/blog.qdac.cc\/?p=4538","title":{"rendered":"[\u6742\u8c08]Objective C\u5bf9\u8c61\u7684\u751f\u547d\u5468\u671f"},"content":{"rendered":"<p>OC \u5df2\u7ecf\u968f\u7740\u82f9\u679c\u7684\u5f88\u591a\u5e74\u5934\u4e86\uff0c\u8fd9\u91cc\u8bf4\u7684 OC \u662f XCode 8.3 \u81ea\u5e26\u7684\u7248\u672c\uff0c\u5c06\u6765\u6216\u8005\u8fc7\u53bb\u7684\u7248\u672c\u4e0d\u5728\u672c\u6587\u7684\u8ba8\u8bba\u8303\u56f4\uff1a<\/p>\n<p>1\uff64\u7c7b\u578b\u521d\u59cb\u5316\u51fd\u6570 +load<\/p>\n<p>\u8fd9\u662f\u7c7b\u578b\u5168\u5c40\u51fd\u6570\uff0c\u5728\u4f60\u7a0b\u5e8f\u542f\u52a8\u65f6\uff0c\u4e0d\u7ba1\u4f60\u7a0b\u5e8f\u91cf\u662f\u5426\u4f7f\u7528\u4e86\u8be5\u7c7b\u578b\uff0c\u5b83\u90fd\u4f1a\u81ea\u52a8\u88ab\u8c03\u7528\u3002<\/p>\n<p>2\uff64\u61d2\u52a0\u8f7d\u521d\u59cb\u5316\u51fd\u6570 +initialize<\/p>\n<p>\u8fd9\u4e2a\u4e5f\u662f\u7c7b\u578b\u7684\u5168\u5c40\u51fd\u6570\uff0c\u5728\u4f60\u7b2c\u4e00\u6b21\u5f15\u7528\u8be5\u7c7b\u578b\u7684\u5b9e\u4f8b\u65f6\uff0c\u4f1a\u88ab\u8c03\u7528\u3002\u5982\u679c\u4f60\u7684\u7a0b\u5e8f\u91cc\u6ca1\u6709\u5bf9\u8be5\u7c7b\u578b\u7684\u5f15\u7528\u6216\u64cd\u4f5c\uff0c\u90a3\u4e48\u5b83\u5c31\u4e0d\u4f1a\u88ab\u8c03\u7528\u3002<\/p>\n<p>3\uff64\u7c7b\u578b\u7684\u6790\u6784\u51fd\u6570 -dealloc<\/p>\n<p>\u8fd9\u4e2a\u51fd\u6570\u662f\u7c7b\u578b\u7684\u6210\u5458\u51fd\u6570\uff0c\u5b83\u5728 OC \u7684\u5783\u573e\u56de\u6536\u673a\u5236\u8981\u91ca\u653e\u4f60\u7684\u5bf9\u8c61\u5b9e\u4f8b\u65f6\u88ab\u8c03\u7528\uff0c\u4ee5\u4fbf\u505a\u76f8\u5e94\u7684\u6e05\u7406\u3002<\/p>\n<p>4\uff64\u5bf9\u8c61\u7684\u5f15\u7528\u8ba1\u6570<\/p>\n<p>\u5bf9\u8c61\u7684\u5f53\u524d\u5f15\u7528\u8ba1\u6570\u53ef\u4ee5\u7528\u00a0CFGetRetainCount \u6765\u83b7\u53d6\uff0c\u6b63\u5e38 OC \u7684\u5bf9\u8c61\u7684\u5f15\u7528\u8ba1\u6570\u548c\u666e\u901a\u7684\u63a5\u53e3\u7684\u89c4\u5219\u662f\u4e00\u81f4\u7684\uff0c\u5373\u5b83\u6bcf\u88ab\u5f15\u7528\u4e00\u6b21\uff0c\u8ba1\u6570\u52a0\u4e00\uff0c\u53d6\u6d88\u4e00\u6b21\u5f15\u7528\uff0c\u8ba1\u6570\u51cf\u4e00\uff0c\u51cf\u5c11\u5230 0 \u65f6\uff0c\u5bf9\u8c61\u88ab\u91ca\u653e\u56de\u6536\u3002<\/p>\n<p>\u5982\u679c\u4e0d\u60f3\u5f15\u7528\u8ba1\u6570\u53d8\u66f4\uff0c\u53ef\u4ee5\u4f7f\u7528 __weak \u4fee\u9970\u53d8\u91cf\uff0c\u5c5e\u6027\u7528 weak\u3002\u901a\u8fc7\u8fd9\u4e00\u70b9\uff0c\u53ef\u4ee5\u6709\u6548\u7684\u907f\u514d\u5faa\u73af\u5f15\u7528\u7684\u95ee\u9898\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"<p>OC \u5df2\u7ecf\u968f\u7740\u82f9\u679c\u7684\u5f88\u591a\u5e74\u5934\u4e86\uff0c\u8fd9\u91cc\u8bf4\u7684 [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"site-sidebar-layout":"default","site-content-layout":"","ast-site-content-layout":"default","site-content-style":"default","site-sidebar-style":"default","ast-global-header-display":"","ast-banner-title-visibility":"","ast-main-header-display":"","ast-hfb-above-header-display":"","ast-hfb-below-header-display":"","ast-hfb-mobile-header-display":"","site-post-title":"","ast-breadcrumbs-content":"","ast-featured-img":"","footer-sml-layout":"","ast-disable-related-posts":"","theme-transparent-header-meta":"","adv-header-id-meta":"","stick-header-meta":"","header-above-stick-meta":"","header-main-stick-meta":"","header-below-stick-meta":"","astra-migrate-meta-layouts":"default","ast-page-background-enabled":"default","ast-page-background-meta":{"desktop":{"background-color":"var(--ast-global-color-4)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"tablet":{"background-color":"","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"mobile":{"background-color":"","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""}},"ast-content-background-meta":{"desktop":{"background-color":"var(--ast-global-color-5)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"tablet":{"background-color":"var(--ast-global-color-5)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"mobile":{"background-color":"var(--ast-global-color-5)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""}},"footnotes":""},"categories":[8],"tags":[718,717,720,719],"class_list":["post-4538","post","type-post","status-publish","format-standard","hentry","category-delphi","tag-objective-c","tag-oc","tag-720","tag-719"],"views":2921,"_links":{"self":[{"href":"https:\/\/blog.qdac.cc\/index.php?rest_route=\/wp\/v2\/posts\/4538","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/blog.qdac.cc\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/blog.qdac.cc\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/blog.qdac.cc\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/blog.qdac.cc\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=4538"}],"version-history":[{"count":1,"href":"https:\/\/blog.qdac.cc\/index.php?rest_route=\/wp\/v2\/posts\/4538\/revisions"}],"predecessor-version":[{"id":4539,"href":"https:\/\/blog.qdac.cc\/index.php?rest_route=\/wp\/v2\/posts\/4538\/revisions\/4539"}],"wp:attachment":[{"href":"https:\/\/blog.qdac.cc\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=4538"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blog.qdac.cc\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=4538"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blog.qdac.cc\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=4538"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}