{"id":42413,"date":"2023-12-11T14:56:30","date_gmt":"2023-12-11T06:56:30","guid":{"rendered":"https:\/\/wx.kaifamiao.info\/?p=42413"},"modified":"2023-12-11T14:56:30","modified_gmt":"2023-12-11T06:56:30","slug":"ios%e5%bc%80%e5%8f%91%ef%bc%9aobjective-c%e4%b8%ad%e9%80%9a%e7%9f%a5%e4%b8%8e%e5%8d%8f%e8%ae%ae%e7%9a%84%e5%8c%ba%e5%88%ab%ef%bc%9f","status":"publish","type":"post","link":"http:\/\/wx.kaifamiao.info\/index.php\/2023\/12\/11\/ios%e5%bc%80%e5%8f%91%ef%bc%9aobjective-c%e4%b8%ad%e9%80%9a%e7%9f%a5%e4%b8%8e%e5%8d%8f%e8%ae%ae%e7%9a%84%e5%8c%ba%e5%88%ab%ef%bc%9f\/","title":{"rendered":"iOS\u5f00\u53d1\uff1aObjective-C\u4e2d\u901a\u77e5\u4e0e\u534f\u8bae\u7684\u533a\u522b\uff1f"},"content":{"rendered":"<p>&#8220;`&#8221;                     what is difference between NSNotification and protocol? \uff08\u901a\u77e5\u548c\u534f\u8bae\u7684\u4e0d\u540c\u4e4b\u5904\uff1f\uff09<\/p>\n<p>\u6211\u60f3\u5927\u5bb6\u90fd\u77e5\u9053\u8fd9\u4e2a\u4e1c\u897f\u600e\u4e48\u7528,\u4f46\u662f\u66f4\u6df1\u5c42\u6b21\u7684\u601d\u8003\u53ef\u80fd\u5c31\u6bd4\u8f83\u5c11\u4e86\u5427,\u4f17\u6240\u5468\u77e5\u5c31\u662f\u4ee3\u7406\u662f\u4e00\u5bf9\u4e00\u7684,\u4f46\u662f\u901a\u77e5\u662f\u53ef\u4ee5\u591a\u5bf9\u591a\u7684.\u4f46\u662f\u4e3a\u4ec0\u4e48\u662f\u8fd9\u4e2a\u6837\u5b50,\u6709\u6ca1\u6709\u66f4\u6df1\u7684\u601d\u8003\u8fc7\u8fd9\u4e2a\u95ee\u9898?<\/p>\n<p>\u4eca\u5929\u770b\u4e86\u4e0b\u7f51\u4e0a\u7684\u51e0\u4e2a\u89c6\u9891\u6559\u7a0b\uff0cKVO\u3001KVC\u3001\u8c13\u8bcd\u3001\u901a\u77e5\uff0c\u7b97\u662f\u5f00\u53d1\u4e2d\u7684\u9ad8\u7ea7\u70b9\u7684\u4e1c\u897f\u4e86\u3002\u901a\u77e5\u548c\u534f\u8bae\u90fd\u662f\u7c7b\u4f3c\u4e8e\u56de\u8c03\u4e00\u6837\uff0c\u4e8e\u662f\u5c31\u5728\u601d\u8003\u901a\u77e5\u548c\u534f\u8bae\u5230\u5e95\u6709\u4ec0\u4e48\u4e0d\u540c\uff0c\u6216\u8005\u8bf4\u4ec0\u4e48\u65f6\u5019\u8be5\u7528\u901a\u77e5\uff0c\u4ec0\u4e48\u65f6\u5019\u8be5\u7528\u534f\u8bae\u3002<\/p>\n<p>\u4e0b\u9762\u662f\u7f51\u4e0a\u6458\u6284\u7684\u4e00\u6bb5\u89e3\u91ca:<\/p>\n<p>\u534f\u8bae\u6709\u63a7\u5236\u94fe(has-a)\u7684\u5173\u7cfb\uff0c\u901a\u77e5\u6ca1\u6709\u3002\u9996\u5148\u6211\u4e00\u5f00\u59cb\u4e5f\u4e0d\u592a\u660e\u767d\uff0c\u4ec0\u4e48\u53eb\u63a7\u5236\u94fe\uff08\u4e13\u4e1a\u672f\u8bed\u4e86~\uff09\u3002\u4f46\u662f\u7b80\u5355\u5206\u6790\u4e0b\u901a\u77e5\u548c\u4ee3\u7406\u7684\u884c\u4e3a\u6a21\u5f0f\uff0c\u6211\u4eec\u5927\u81f4\u53ef\u4ee5\u6709\u81ea\u5df1\u7684\u7406\u89e3\u7b80\u5355\u6765\u8bf4\uff0c\u901a\u77e5\u7684\u8bdd\uff0c\u5b83\u53ef\u4ee5\u4e00\u5bf9\u591a\uff0c\u4e00\u6761\u6d88\u606f\u53ef\u4ee5\u53d1\u9001\u7ed9\u591a\u4e2a\u6d88\u606f\u63a5\u53d7\u8005\u3002\u4ee3\u7406\u6309\u6211\u4eec\u7684\u7406\u89e3\uff0c\u5230\u4e0d\u662f\u76f4\u63a5\u8bf4\u4e0d\u80fd\u4e00\u5bf9\u591a\uff0c\u6bd4\u5982\u6211\u4eec\u77e5\u9053\u7684\u660e\u661f\u7ecf\u6d4e\u4ee3\u7406\u4eba\uff0c\u5f88\u591a\u65f6\u5019\u4e00\u4e2a\u7ecf\u6d4e\u4eba\u8d1f\u8d23\u597d\u51e0\u4e2a\u660e\u661f\u7684\u4e8b\u52a1\u3002\u53ea\u662f\u5bf9\u4e8e\u4e0d\u540c\u660e\u661f\u95f4\uff0c\u4ee3\u7406\u7684\u4e8b\u7269\u5bf9\u8c61\u90fd\u662f\u4e0d\u4e00\u6837\u7684\uff0c\u4e00\u4e00\u5bf9\u5e94\uff0c\u4e0d\u53ef\u80fd\u8bf4\u660e\u5929\u8981\u5904\u7406A\u660e\u661f\u8981\u4e00\u4e2a\u53d1\u5e03\u4f1a\uff0c\u4ee3\u7406\u4eba\u53d1\u51fa\u5904\u7406\u53d1\u5e03\u4f1a\u7684\u6d88\u606f\u540e\uff0c\u522b\u79f0B\u7684\u53d1\u5e03\u4f1a\u4e86\u3002\u4f46\u662f\u901a\u77e5\u5c31\u4e0d\u4e00\u6837\uff0c\u4ed6\u53ea\u5173\u5fc3\u53d1\u51fa\u901a\u77e5\uff0c\u800c\u4e0d\u5173\u5fc3\u591a\u5c11\u63a5\u6536\u5230\u611f\u5174\u8da3\u8981\u5904\u7406\u3002\u56e0\u6b64\u63a7\u5236\u94fe\uff08has-a\u4ece\u82f1\u8bed\u5355\u8bcd\u5927\u81f4\u53ef\u4ee5\u770b\u51fa\uff0c\u5355\u4e00\u62e5\u6709\u548c\u53ef\u63a7\u5236\u7684\u5bf9\u5e94\u5173\u7cfb\u3002<\/p>\n<p>1.\u901a\u77e5:<\/p>\n<p>\u901a\u77e5\u9700\u8981\u6709\u4e00\u4e2a\u901a\u77e5\u4e2d\u5fc3\uff1aNSNotificationCenter\uff0c\u81ea\u5b9a\u4e49\u901a\u77e5\u7684\u8bdd\u9700\u8981\u7ed9\u4e00\u4e2a\u540d\u5b57\uff0c\u7136\u540e\u76d1\u542c\u3002<\/p>\n<p>\u4f18\u70b9:\u901a\u77e5\u7684\u53d1\u9001\u8005\u548c\u63a5\u53d7\u8005\u90fd\u4e0d\u9700\u8981\u77e5\u9053\u5bf9\u65b9\u3002\u53ef\u4ee5\u6307\u5b9a\u63a5\u6536\u901a\u77e5\u7684\u5177\u4f53\u65b9\u6cd5\u3002\u901a\u77e5\u540d\u53ef\u4ee5\u662f\u4efb\u4f55\u5b57\u7b26\u4e32\u3002<\/p>\n<p>\u7f3a\u70b9:\u8f83\u952e\u503c\u89c2\u5bdf\uff08KVO\uff09\u9700\u8981\u591a\u70b9\u4ee3\u7801\uff0c\u5728\u5220\u6389\u524d\u5fc5\u987b\u79fb\u9664\u76d1\u542c\u8005\u3002<\/p>\n<p>2.\u534f\u8bae<\/p>\n<p>\u901a\u8fc7setDelegate\u6765\u8bbe\u7f6e\u4ee3\u7406\u5bf9\u8c61\uff0c\u6700\u5178\u578b\u7684\u4f8b\u5b50\u662f\u5e38\u7528\u7684TableView.<\/p>\n<p>\u4f18\u70b9:\u652f\u6301\u5b83\u7684\u7c7b\u6709\u8be6\u5c3d\u548c\u5177\u4f53\u4fe1\u606f\u3002<\/p>\n<p>\u7f3a\u70b9:\u8be5\u7c7b\u5fc5\u987b\u652f\u6301\u59d4\u6258\u3002\u67d0\u4e00\u65f6\u95f4\u53ea\u80fd\u6709\u4e00\u4e2a\u59d4\u6258\u8fde\u63a5\u5230\u67d0\u4e00\u5bf9\u8c61\u3002<\/p>\n<p>\u76f8\u4fe1\u770b\u5230\u8fd9\u4e9b\u4e1c\u897f,\u8ba4\u771f\u601d\u8003\u4e00\u4e0b,\u5c31\u53ef\u4ee5\u77e5\u9053\u5728\u90a3\u79cd\u60c5\u51b5\u4e0b\u4f7f\u7528\u901a\u77e5,\u5728\u90a3\u79cd\u60c5\u51b5\u4e0b\u4f7f\u7528\u4ee3\u7406\u4e86\u5427.<\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<pre><code>            \"```\n<\/code><\/pre>\n","protected":false},"excerpt":{"rendered":"<p>&#8220;`&#8221; what is difference between NSNotificati [&hellip;]<\/p>\n","protected":false},"author":7,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[101],"tags":[],"class_list":["post-42413","post","type-post","status-publish","format-standard","hentry","category-c"],"_links":{"self":[{"href":"http:\/\/wx.kaifamiao.info\/index.php\/wp-json\/wp\/v2\/posts\/42413","targetHints":{"allow":["GET"]}}],"collection":[{"href":"http:\/\/wx.kaifamiao.info\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/wx.kaifamiao.info\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/wx.kaifamiao.info\/index.php\/wp-json\/wp\/v2\/users\/7"}],"replies":[{"embeddable":true,"href":"http:\/\/wx.kaifamiao.info\/index.php\/wp-json\/wp\/v2\/comments?post=42413"}],"version-history":[{"count":1,"href":"http:\/\/wx.kaifamiao.info\/index.php\/wp-json\/wp\/v2\/posts\/42413\/revisions"}],"predecessor-version":[{"id":42414,"href":"http:\/\/wx.kaifamiao.info\/index.php\/wp-json\/wp\/v2\/posts\/42413\/revisions\/42414"}],"wp:attachment":[{"href":"http:\/\/wx.kaifamiao.info\/index.php\/wp-json\/wp\/v2\/media?parent=42413"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/wx.kaifamiao.info\/index.php\/wp-json\/wp\/v2\/categories?post=42413"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/wx.kaifamiao.info\/index.php\/wp-json\/wp\/v2\/tags?post=42413"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}