{"id":88768,"date":"2025-07-06T23:01:54","date_gmt":"2025-07-06T16:01:54","guid":{"rendered":"https:\/\/itviec.com\/blog\/?p=88768"},"modified":"2025-07-07T16:33:00","modified_gmt":"2025-07-07T09:33:00","slug":"cau-hoi-phong-van-objective-c","status":"publish","type":"post","link":"https:\/\/itviec.com\/blog\/cau-hoi-phong-van-objective-c\/","title":{"rendered":"Top 30+ c\u00e2u h\u1ecfi ph\u1ecfng v\u1ea5n Objective-C t\u1eeb l\u00fd thuy\u1ebft \u0111\u1ebfn th\u1ef1c h\u00e0nh"},"content":{"rendered":"<div id=\"ez-toc-container\" class=\"ez-toc-v2_0_84 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\" style=\"cursor:inherit\">N\u1ed9i dung b\u00e0i vi\u1ebft<\/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-2'><a class=\"ez-toc-link ez-toc-heading-1\" href=\"https:\/\/itviec.com\/blog\/cau-hoi-phong-van-objective-c\/#Cau_hoi_phong_van_Objective-C_muc_so_cap_Junior_Level\" >C\u00e2u h\u1ecfi ph\u1ecfng v\u1ea5n Objective-C m\u1ee9c s\u01a1 c\u1ea5p (Junior Level)<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-2\" href=\"https:\/\/itviec.com\/blog\/cau-hoi-phong-van-objective-c\/#Cau_hoi_phong_van_Objective-C_trung_cap_Middle_Level\" >C\u00e2u h\u1ecfi ph\u1ecfng v\u1ea5n Objective-C trung c\u1ea5p (Middle Level)<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-3\" href=\"https:\/\/itviec.com\/blog\/cau-hoi-phong-van-objective-c\/#Cau_hoi_phong_van_Objective-C_cap_do_cao_Senior_Level\" >C\u00e2u h\u1ecfi ph\u1ecfng v\u1ea5n Objective-C c\u1ea5p \u0111\u1ed9 cao (Senior Level)<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-4\" href=\"https:\/\/itviec.com\/blog\/cau-hoi-phong-van-objective-c\/#Cau_hoi_thuc_hanh_Objective-C\" >C\u00e2u h\u1ecfi th\u1ef1c h\u00e0nh Objective-C&nbsp;<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-5\" href=\"https:\/\/itviec.com\/blog\/cau-hoi-phong-van-objective-c\/#Tong_ket\" >T\u1ed5ng k\u1ebft<\/a><\/li><\/ul><\/nav><\/div>\n\n<p><strong><em>N\u1ebfu b\u1ea1n \u0111ang chu\u1ea9n b\u1ecb cho m\u1ed9t bu\u1ed5i ph\u1ecfng v\u1ea5n v\u1ecb tr\u00ed l\u1eadp tr\u00ecnh vi\u00ean iOS, c\u00f3 th\u1ec3 b\u1ea1n s\u1ebd g\u1eb7p nh\u1eefng c\u00e2u h\u1ecfi xoay quanh Objective-C. B\u1edfi l\u1ebd Objective-C v\u1eabn hi\u1ec7n di\u1ec7n trong nhi\u1ec1u d\u1ef1 \u00e1n c\u0169 v\u00e0 \u0111\u00f2i h\u1ecfi b\u1ea1n ph\u1ea3i hi\u1ec3u r\u00f5 m\u1edbi c\u00f3 th\u1ec3 b\u1ea3o tr\u00ec ho\u1eb7c m\u1edf r\u1ed9ng. Trong b\u00e0i vi\u1ebft n\u00e0y, ITviec \u0111\u00e3 t\u1ed5ng h\u1ee3p h\u01a1n 30 c\u00e2u h\u1ecfi ph\u1ecfng v\u1ea5n Objective-C t\u1eeb l\u00fd thuy\u1ebft \u0111\u1ebfn th\u1ef1c h\u00e0nh. C\u00f9ng t\u00ecm hi\u1ec3u v\u00e0 luy\u1ec7n t\u1eadp tr\u01b0\u1edbc khi b\u01b0\u1edbc v\u00e0o ph\u1ecfng v\u1ea5n nh\u00e9!<\/em><\/strong><\/p>\n\n\n\n<p>\u0110\u1ecdc b\u00e0i vi\u1ebft \u0111\u1ec3 hi\u1ec3u r\u00f5 h\u01a1n:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>C\u00e2u h\u1ecfi ph\u1ecfng v\u1ea5n Objective-C m\u1ee9c s\u01a1 c\u1ea5p (Junior Level)<\/li>\n\n\n\n<li>C\u00e2u h\u1ecfi ph\u1ecfng v\u1ea5n Objective-C m\u1ee9c trung c\u1ea5p (Middle Level)<\/li>\n\n\n\n<li>C\u00e2u h\u1ecfi ph\u1ecfng v\u1ea5n Objective-C m\u1ee9c cao c\u1ea5p (Senior Level)<\/li>\n<\/ul>\n\n\n\n<blockquote class=\"wp-block-quote is-layout-flow wp-block-quote-is-layout-flow\">\n<p><em>\u0110\u1ecdc chi ti\u1ebft: <strong><a href=\"https:\/\/itviec.com\/blog\/objective-c-la-gi\/\" target=\"_blank\" rel=\"noreferrer noopener\">Objective-C l\u00e0 g\u00ec? C\u00f3 c\u00f2n ph\u00f9 h\u1ee3p \u0111\u1ec3 h\u1ecdc trong n\u0103m 2025?<\/a><\/strong><\/em><\/p>\n<\/blockquote>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"h-cau-h\u1ecfi-ph\u1ecfng-v\u1ea5n-objective-c-m\u1ee9c-s\u01a1-c\u1ea5p-junior-level\"><span class=\"ez-toc-section\" id=\"Cau_hoi_phong_van_Objective-C_muc_so_cap_Junior_Level\"><\/span><strong>C\u00e2u h\u1ecfi ph\u1ecfng v\u1ea5n Objective-C m\u1ee9c s\u01a1 c\u1ea5p (Junior Level)<\/strong><span class=\"ez-toc-section-end\"><\/span><\/h2>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"h-objective-c-h\u1ed7-tr\u1ee3-ki\u1ec3u-d\u1eef-li\u1ec7u-d\u1ed9ng-nh\u01b0-th\u1ebf-nao\"><strong>Objective-C h\u1ed7 tr\u1ee3 ki\u1ec3u d\u1eef li\u1ec7u \u0111\u1ed9ng nh\u01b0 th\u1ebf n\u00e0o?<\/strong><\/h3>\n\n\n\n<p>Objective-C h\u1ed7 tr\u1ee3 ki\u1ec3u d\u1eef li\u1ec7u \u0111\u1ed9ng (dynamic typing) th\u00f4ng qua bi\u1ebfn \u0111\u1eb7c bi\u1ec7t <strong>id<\/strong>. Bi\u1ebfn id c\u00f3 th\u1ec3 l\u01b0u tr\u1eef b\u1ea5t k\u1ef3 \u0111\u1ed1i t\u01b0\u1ee3ng n\u00e0o m\u00e0 kh\u00f4ng c\u1ea7n x\u00e1c \u0111\u1ecbnh ki\u1ec3u c\u1ee5 th\u1ec3 t\u1ea1i th\u1eddi \u0111i\u1ec3m bi\u00ean d\u1ecbch. T\u1eeb \u0111\u00f3 mang l\u1ea1i s\u1ef1 linh ho\u1ea1t cao trong vi\u1ec7c x\u1eed l\u00fd \u0111\u1ed1i t\u01b0\u1ee3ng.<\/p>\n\n\n\n<p>B\u00ean c\u1ea1nh \u0111\u00f3, Objective-C c\u00f2n cung c\u1ea5p c\u00e1c ph\u01b0\u01a1ng th\u1ee9c ki\u1ec3m tra ki\u1ec3m t\u1ea1i th\u1eddi \u0111i\u1ec3m ch\u1ea1y nh\u01b0 <code>respondsToSelector:<\/code>, <code>isKindOfClass:<\/code>, <code>isMemberOfClass:<\/code> ho\u1eb7c <code>conformsToProtocol:<\/code>. Nh\u1eefng c\u00f4ng c\u1ee5 n\u00e0y gi\u00fap \u0111\u1ea3m b\u1ea3o an to\u00e0n khi l\u00e0m vi\u1ec7c v\u1edbi c\u00e1c \u0111\u1ed1i t\u01b0\u1ee3ng c\u00f3 ki\u1ec3u kh\u00f4ng c\u1ed1 \u0111\u1ecbnh.<\/p>\n\n\n\n<p>Ngo\u00e0i ra, h\u1ec7 th\u1ed1ng runtime message passing c\u00f2n cho ph\u00e9p Objective-C g\u1eedi th\u00f4ng \u0111i\u1ec7p \u0111\u1ebfn \u0111\u1ed1i t\u01b0\u1ee3ng m\u00e0 kh\u00f4ng c\u1ea7n ki\u1ec3m tra ki\u1ec3u tr\u01b0\u1edbc, t\u1ea1o \u0111i\u1ec1u ki\u1ec7n \u0111\u1ec3 c\u00e1c \u0111\u1ed1i t\u01b0\u1ee3ng \u0111a h\u00ecnh (polymorphic) ho\u1ea1t \u0111\u1ed9ng m\u1ed9t c\u00e1ch linh ho\u1ea1t v\u00e0 t\u1ef1 do h\u01a1n trong qu\u00e1 tr\u00ecnh th\u1ef1c thi.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"h-gi\u1ea3i-thich-khai-ni\u1ec7m-g\u1eedi-tin-nh\u1eafn-trong-objective-c\"><strong>Gi\u1ea3i th\u00edch kh\u00e1i ni\u1ec7m g\u1eedi tin nh\u1eafn trong Objective-C.<\/strong><\/h3>\n\n\n\n<p>Trong Objective-C, kh\u00e1i ni\u1ec7m \u201cg\u1eedi tin nh\u1eafn&#8221; (message sending) l\u00e0 c\u01a1 ch\u1ebf \u0111\u01b0\u1ee3c s\u1eed d\u1ee5ng \u0111\u1ec3 g\u1ecdi ph\u01b0\u01a1ng th\u1ee9c tr\u00ean m\u1ed9t \u0111\u1ed1i t\u01b0\u1ee3ng. Kh\u00e1c v\u1edbi C++ hay Java, Objective-C s\u1ebd g\u1eedi m\u1ed9t th\u00f4ng \u0111i\u1ec7p \u0111\u1ebfn \u0111\u1ed1i t\u01b0\u1ee3ng n\u00e0y v\u00e0 \u0111\u1ed1i t\u01b0\u1ee3ng \u0111\u00f3 s\u1ebd quy\u1ebft \u0111\u1ecbnh c\u00f3 th\u1ef1c thi hay kh\u00f4ng.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"h-s\u1ef1-khac-bi\u1ec7t-gi\u1eefa-import-va-include-trong-objective-c-la-gi\"><strong>S\u1ef1 kh\u00e1c bi\u1ec7t gi\u1eefa #import v\u00e0 #include trong Objective-C l\u00e0 g\u00ec?<\/strong><\/h3>\n\n\n\n<p>Trong Objective-C, c\u1ea3 <code>#import<\/code> v\u00e0 <code>#include<\/code> \u0111\u1ec1u \u0111\u01b0\u1ee3c d\u00f9ng \u0111\u1ec3 ch\u00e8n n\u1ed9i dung c\u1ee7a file header v\u00e0o file hi\u1ec7n t\u1ea1i. Tuy nhi\u00ean, hai ch\u1ec9 th\u1ecb n\u00e0y c\u00f3 c\u00e1ch ho\u1ea1t \u0111\u1ed9ng kh\u00e1c nhau.<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li><code>#import<\/code>: Ch\u1ec9 ch\u00e8n file m\u1ed9t l\u1ea7n duy nh\u1ea5t, b\u1ea5t k\u1ec3 \u0111\u01b0\u1ee3c g\u1ecdi nhi\u1ec1u l\u1ea7n trong m\u00e3 ngu\u1ed3n. Ch\u1ec9 th\u1ecb n\u00e0y gi\u00fap tr\u00e1nh t\u00ecnh tr\u1ea1ng ch\u00e8n tr\u00f9ng l\u1eb7p, t\u1eeb \u0111\u00f3 ng\u0103n ng\u1eeba l\u1ed7i bi\u00ean d\u1ecbch do \u0111\u1ecbnh ngh\u0129a tr\u00f9ng l\u1eb7p.<\/li>\n\n\n\n<li><code>#include<\/code>: M\u1ed7i l\u1ea7n \u0111\u01b0\u1ee3c g\u1ecdi, n\u1ed9i dung file s\u1ebd \u0111\u01b0\u1ee3c ch\u00e8n l\u1ea1i. \u0110\u1ec3 tr\u00e1nh ch\u00e8n tr\u00f9ng l\u1eb7p, l\u1eadp tr\u00ecnh vi\u00ean ph\u1ea3i d\u00f9ng th\u00eam c\u00e1c ch\u1ec9 th\u1ecb ti\u1ec1n x\u1eed l\u00fd nh\u01b0 <code>#ifndef<\/code>, <code>#define<\/code> v\u00e0 <code>#endif.<\/code><\/li>\n<\/ul>\n\n\n\n<p>V\u00ec s\u1ef1 ti\u1ec7n l\u1ee3i v\u00e0 an to\u00e0n, <code>#import<\/code> \u0111\u01b0\u1ee3c \u01b0u ti\u00ean trong h\u1ea7u h\u1ebft c\u00e1c d\u1ef1 \u00e1n Objective-C hi\u1ec7n \u0111\u1ea1i.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"h-gi\u1ea3i-thich-s\u1ef1-khac-bi\u1ec7t-gi\u1eefa-tinh-ch\u1ea5t-atomic-va-nonatomic-trong-objective-c\"><strong>Gi\u1ea3i th\u00edch s\u1ef1 kh\u00e1c bi\u1ec7t gi\u1eefa t\u00ednh ch\u1ea5t atomic v\u00e0 nonatomic trong Objective-C.<\/strong><\/h3>\n\n\n\n<p>Trong Objective-C, khi khai b\u00e1o thu\u1ed9c t\u00ednh (<code>@property<\/code>), l\u1eadp tr\u00ecnh vi\u00ean c\u00f3 th\u1ec3 ch\u1ec9 \u0111\u1ecbnh t\u00ednh ch\u1ea5t atomic ho\u1eb7c nonatomic \u0111\u1ec3 ki\u1ec3m so\u00e1t c\u00e1ch thu\u1ed9c t\u00ednh \u0111\u00f3 \u0111\u01b0\u1ee3c truy c\u1eadp trong m\u00f4i tr\u01b0\u1eddng \u0111a lu\u1ed3ng. Trong \u0111\u00f3:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong>Atomic: <\/strong>Mang \u0111\u1ebfn c\u01a1 ch\u1ebf \u0111\u1ed3ng b\u1ed9 gi\u1eefa c\u00e1c lu\u1ed3ng, ph\u00f9 h\u1ee3p khi c\u1ea7n \u0111\u1ea3m b\u1ea3o t\u00ednh to\u00e0n v\u1eb9n d\u1eef li\u1ec7u trong \u1ee9ng d\u1ee5ng \u0111a lu\u1ed3ng. Tuy nhi\u00ean, atomic kh\u00f4ng \u0111\u1ea3m b\u1ea3o \u0111\u1ed1i t\u01b0\u1ee3ng fully thread-safe. V\u1edbi atomic, khi m\u1ed9t lu\u1ed3ng \u0111ang \u0111\u1ecdc ho\u1eb7c ghi d\u1eef li\u1ec7u, c\u00e1c lu\u1ed3ng kh\u00e1c s\u1ebd ph\u1ea3i ch\u1edd cho \u0111\u1ebfn khi thao t\u00e1c ho\u00e0n t\u1ea5t, gi\u00fap tr\u00e1nh xung \u0111\u1ed9t d\u1eef li\u1ec7u nh\u01b0ng c\u00f3 th\u1ec3 l\u00e0m gi\u1ea3m hi\u1ec7u n\u0103ng.<\/li>\n\n\n\n<li><strong>Nonatomic: <\/strong>Kh\u00f4ng c\u00f3 c\u01a1 ch\u1ebf \u0111\u1ed3ng b\u1ed9 n\u00ean c\u00e1c lu\u1ed3ng c\u00f3 th\u1ec3 ho\u1ea1t \u0111\u1ed9ng song song, ch\u1ed3ng ch\u00e9o l\u00ean nhau. Th\u01b0\u1eddng \u0111\u01b0\u1ee3c d\u00f9ng trong c\u00e1c t\u00ecnh hu\u1ed1ng \u0111\u01a1n lu\u1ed3ng ho\u1eb7c khi hi\u1ec7u n\u0103ng l\u00e0 y\u1ebfu t\u1ed1 \u01b0u ti\u00ean. V\u1edbi nonatomic, vi\u1ec7c truy c\u1eadp v\u00e0 thay \u0111\u1ed5i d\u1eef li\u1ec7u di\u1ec5n ra nhanh h\u01a1n nh\u01b0ng \u0111\u1ed5i l\u1ea1i c\u00f3 th\u1ec3 x\u1ea3y ra l\u1ed7i ho\u1eb7c h\u00e0nh vi kh\u00f4ng x\u00e1c \u0111\u1ecbnh.&nbsp;&nbsp;<\/li>\n<\/ul>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"h-delegate-la-gi-delegate-co-th\u1ec3-d\u01b0\u1ee3c-gi\u1eef-l\u1ea1i-khong\"><strong>Delegate l\u00e0 g\u00ec? Delegate c\u00f3 th\u1ec3 \u0111\u01b0\u1ee3c gi\u1eef l\u1ea1i kh\u00f4ng?<\/strong><\/h3>\n\n\n\n<p>Delegate l\u00e0 m\u1ed9t \u0111\u1ed1i t\u01b0\u1ee3ng \u0111\u01b0\u1ee3c u\u1ef7 quy\u1ec1n \u0111\u1ec3 th\u1ef1c hi\u1ec7n thay th\u1ebf ho\u1eb7c h\u1ed7 tr\u1ee3 x\u1eed l\u00fd m\u1ed9t h\u00e0nh \u0111\u1ed9ng, th\u01b0\u1eddng l\u00e0 \u0111\u1ec3 ph\u1ea3n h\u1ed3i c\u00e1c s\u1ef1 ki\u1ec7n. Delegate cho ph\u00e9p c\u00e1c l\u1edbp giao ti\u1ebfp linh ho\u1ea1t v\u1edbi nhau theo m\u00f4 h\u00ecnh \u201cb\u00ean A g\u1eedi y\u00eau c\u1ea7u &#8211; b\u00ean B ph\u1ea3n h\u1ed3i\u201d m\u00e0 kh\u00f4ng c\u1ea7n r\u00e0ng bu\u1ed9c tr\u1ef1c ti\u1ebfp v\u1ec1 m\u1eb7t c\u1ea5u tr\u00fac.<\/p>\n\n\n\n<p>V\u1ec1 m\u1eb7t k\u1ef9 thu\u1eadt, delegate c\u00f3 th\u1ec3 \u0111\u01b0\u1ee3c gi\u1eef l\u1ea1i n\u1ebfu thu\u1ed9c t\u00ednh delegate \u0111\u01b0\u1ee3c khai b\u00e1o v\u1edbi t\u1eeb kho\u00e1 strong. Tuy nhi\u00ean, \u0111i\u1ec1u n\u00e0y kh\u00f4ng \u0111\u01b0\u1ee3c khuy\u1ebfn kh\u00edch, v\u00ec delegate th\u01b0\u1eddng \u0111\u00e3 \u0111\u01b0\u1ee3c m\u1ed9t \u0111\u1ed1i t\u01b0\u1ee3ng kh\u00e1c gi\u1eef. N\u1ebfu gi\u1eef l\u1ea1i th\u00eam l\u1ea7n n\u1eefa, c\u00f3 th\u1ec3 d\u1eabn \u0111\u1ebfn v\u00f2ng l\u1eb7p gi\u1eef (retain cycle), khi\u1ebfn b\u1ed9 nh\u1edb kh\u00f4ng \u0111\u01b0\u1ee3c gi\u1ea3i ph\u00f3ng \u0111\u00fang c\u00e1ch.<\/p>\n\n\n\n<p>\u0110\u1ec3 tr\u00e1nh t\u00ecnh tr\u1ea1ng n\u00e0y, delegate n\u00ean \u0111\u01b0\u1ee3c khai b\u00e1o v\u1edbi t\u1eeb kho\u00e1 weak. Vi\u1ec7c s\u1eed d\u1ee5ng weak reference \u0111\u1ea3m b\u1ea3o r\u1eb1ng \u0111\u1ed1i t\u01b0\u1ee3ng gi\u1eef delegate kh\u00f4ng l\u00e0m t\u0103ng s\u1ed1 l\u01b0\u1ee3ng tham chi\u1ebfu \u0111\u1ebfn delegate, t\u1eeb \u0111\u00f3 gi\u00fap tr\u00e1nh retain cycle v\u00e0 \u0111\u1ea3m b\u1ea3o qu\u00e1 tr\u00ecnh qu\u1ea3n l\u00fd b\u1ed9 nh\u1edb di\u1ec5n ra ch\u00ednh x\u00e1c.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"h-lam-th\u1ebf-nao-d\u01b0a-nil-vao-m\u1ed9t-category-m\u1ea3ng\"><strong>L\u00e0m th\u1ebf n\u00e0o \u0111\u01b0a nil v\u00e0o m\u1ed9t category\/m\u1ea3ng?<\/strong><\/h3>\n\n\n\n<p>Trong Objective-C, kh\u00f4ng th\u1ec3 tr\u1ef1c ti\u1ebfp \u0111\u01b0a nil v\u00e0o m\u1ed9t category ho\u1eb7c m\u1ed9t m\u1ea3ng. B\u1edfi nil th\u01b0\u1eddng \u0111\u01b0\u1ee3c d\u00f9ng \u0111\u1ec3 \u0111\u00e1nh d\u1ea5u k\u1ebft th\u00fac danh s\u00e1ch \u0111\u1ed1i t\u01b0\u1ee3ng trong nhi\u1ec1u API. \u0110\u1ed3ng th\u1eddi, nil c\u0169ng kh\u00f4ng ph\u1ea3i l\u00e0 m\u1ed9t \u0111\u1ed1i t\u01b0\u1ee3ng n\u00ean kh\u00f4ng th\u1ec3 \u0111\u01b0\u1ee3c l\u01b0u trong m\u1ea3ng.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"h-neu-hi\u1ec3u-bi\u1ebft-c\u1ee7a-b\u1ea1n-v\u1ec1-protocol-trong-objective-c\"><strong>N\u00eau hi\u1ec3u bi\u1ebft c\u1ee7a b\u1ea1n v\u1ec1 Protocol trong Objective-C.<\/strong><\/h3>\n\n\n\n<p>Protocol trong Objective-C l\u00e0 m\u1ed9t t\u1eadp h\u1ee3p c\u00e1c ph\u01b0\u01a1ng th\u1ee9c m\u00e0 m\u1ed9t l\u1edbp c\u00f3 th\u1ec3 cam k\u1ebft th\u1ef1c hi\u1ec7n. N\u00f3 gi\u1ed1ng nh\u01b0 m\u1ed9t &#8220;giao k\u00e8o&#8221; v\u1ec1 h\u00e0nh vi, \u0111\u1ecbnh ngh\u0129a c\u00e1i g\u00ec c\u1ea7n \u0111\u01b0\u1ee3c th\u1ef1c hi\u1ec7n nh\u01b0ng kh\u00f4ng ch\u1ee9a ph\u1ea7n tri\u1ec3n khai c\u1ee5 th\u1ec3.&nbsp;<\/p>\n\n\n\n<p>Protocol th\u01b0\u1eddng \u0111\u01b0\u1ee3c d\u00f9ng \u0111\u1ec3 \u0111\u1ecbnh ngh\u0129a interface chung cho c\u00e1c \u0111\u1ed1i t\u01b0\u1ee3ng kh\u00f4ng li\u00ean quan v\u1ec1 m\u1eb7t k\u1ebf th\u1eeba, ho\u1eb7c \u0111\u1ec3 thi\u1ebft k\u1ebf delegate pattern. C\u00f3 th\u1ec3 \u0111\u00e1nh d\u1ea5u c\u00e1c ph\u01b0\u01a1ng th\u1ee9c trong protocol l\u00e0 <code>@optional<\/code> ho\u1eb7c <code>@required<\/code>, gi\u00fap linh ho\u1ea1t h\u01a1n khi \u00e1p d\u1ee5ng trong th\u1ef1c t\u1ebf.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"h-cau-h\u1ecfi-ph\u1ecfng-v\u1ea5n-objective-c-trung-c\u1ea5p-middle-level\"><span class=\"ez-toc-section\" id=\"Cau_hoi_phong_van_Objective-C_trung_cap_Middle_Level\"><\/span><strong>C\u00e2u h\u1ecfi ph\u1ecfng v\u1ea5n Objective-C trung c\u1ea5p (Middle Level)<\/strong><span class=\"ez-toc-section-end\"><\/span><\/h2>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"h-hay-mo-t\u1ea3-cach-objective-c-x\u1eed-ly-vi\u1ec7c-qu\u1ea3n-ly-b\u1ed9-nh\u1edb\"><strong>H\u00e3y m\u00f4 t\u1ea3 c\u00e1ch Objective-C x\u1eed l\u00fd vi\u1ec7c qu\u1ea3n l\u00fd b\u1ed9 nh\u1edb.<\/strong><\/h3>\n\n\n\n<p>Objective-C s\u1eed d\u1ee5ng m\u00f4 h\u00ecnh qu\u1ea3n l\u00fd b\u1ed9 nh\u1edb d\u1ef1a tr\u00ean Reference Counting (\u0111\u1ebfm s\u1ed1 l\u01b0\u1ee3ng tham chi\u1ebfu). M\u1ed7i \u0111\u1ed1i t\u01b0\u1ee3ng trong b\u1ed9 nh\u1edb \u0111\u1ec1u c\u00f3 m\u1ed9t b\u1ed9 \u0111\u1ebfm g\u1ecdi l\u00e0 retain count. Khi m\u1ed9t \u0111\u1ed1i t\u01b0\u1ee3ng \u0111\u01b0\u1ee3c t\u1ea1o m\u1edbi ho\u1eb7c \u0111\u01b0\u1ee3c gi\u1eef l\u1ea1i (retained), retain count s\u1ebd t\u0103ng. Ng\u01b0\u1ee3c l\u1ea1i, khi \u0111\u1ed1i t\u01b0\u1ee3ng \u0111\u01b0\u1ee3c gi\u1ea3i ph\u00f3ng (release), retain count s\u1ebd gi\u1ea3m. Khi b\u1ed9 \u0111\u1ebfm b\u1eb1ng 0, \u0111\u1ed1i t\u01b0\u1ee3ng s\u1ebd \u0111\u01b0\u1ee3c t\u1ef1 \u0111\u1ed9ng gi\u1ea3i ph\u00f3ng ho\u00e0n to\u00e0n kh\u1ecfi b\u1ed9 nh\u1edb.<\/p>\n\n\n\n<p>\u0110\u1ec3 \u0111\u01a1n gi\u1ea3n h\u00f3a qu\u00e1 tr\u00ecnh n\u00e0y, Objective-C \u00e1p d\u1ee5ng c\u00f4ng ngh\u1ec7 Automatic Reference Counting (ARC). ARC t\u1ef1 \u0111\u1ed9ng ch\u00e8n c\u00e1c l\u1ec7nh retain, release v\u00e0 autorelease trong qu\u00e1 tr\u00ecnh bi\u00ean d\u1ecbch, gi\u00fap lo\u1ea1i b\u1ecf nhu c\u1ea7u qu\u1ea3n l\u00fd th\u1ee7 c\u00f4ng nh\u01b0 trong m\u00f4 h\u00ecnh Manual Retain-Release (MRR). Nh\u1edd \u0111\u00f3, ARC g\u00f3p ph\u1ea7n gi\u1ea3m thi\u1ec3u l\u1ed7i r\u00f2 r\u1ec9 b\u1ed9 nh\u1edb (memory leak) v\u00e0 l\u1ed7i con tr\u1ecf treo (dangling pointer), \u0111\u1ed3ng th\u1eddi gi\u00fap m\u00e3 ngu\u1ed3n an to\u00e0n v\u00e0 d\u1ec5 b\u1ea3o tr\u00ec h\u01a1n.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"h-c\u01a1-ch\u1ebf-phat-hanh-t\u1ef1-d\u1ed9ng-autorelease-pool-la-gi\"><strong>C\u01a1 ch\u1ebf ph\u00e1t h\u00e0nh t\u1ef1 \u0111\u1ed9ng (Autorelease Pool) l\u00e0 g\u00ec?<\/strong><\/h3>\n\n\n\n<p>Autorelease Pool l\u00e0 m\u1ed9t c\u01a1 ch\u1ebf qu\u1ea3n l\u00fd b\u1ed9 nh\u1edb trong Objective-C, cho ph\u00e9p ho\u00e3n gi\u1ea3i ph\u00f3ng c\u00e1c \u0111\u1ed1i t\u01b0\u1ee3ng \u0111\u00e3 \u0111\u01b0\u1ee3c \u0111\u00e1nh d\u1ea5u autorelease \u0111\u1ebfn khi pool k\u1ebft th\u00fac. C\u01a1 ch\u1ebf n\u00e0y gi\u00fap gi\u1ea3m g\u00e1nh n\u1eb7ng ph\u1ea3i release th\u1ee7 c\u00f4ng t\u1eebng \u0111\u1ed1i t\u01b0\u1ee3ng, \u0111\u1ed3ng th\u1eddi t\u1ed1i \u01b0u hi\u1ec7u n\u0103ng v\u00e0 h\u1ea1n ch\u1ebf r\u00f2 r\u1ec9 b\u1ed9 nh\u1edb, \u0111\u1eb7c bi\u1ec7t trong c\u00e1c v\u00f2ng l\u1eb7p t\u1ea1o nhi\u1ec1u \u0111\u1ed1i t\u01b0\u1ee3ng t\u1ea1m th\u1eddi.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"h-vai-tro-c\u1ee7a-selector-trong-objective-c-la-gi\"><strong>Vai tr\u00f2 c\u1ee7a @selector trong Objective-C l\u00e0 g\u00ec?<\/strong><\/h3>\n\n\n\n<p><code>Selector<\/code> trong Objective-C c\u00f3 hai vai tr\u00f2:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong>Khi vi\u1ebft m\u00e3: <\/strong>Selector \u0111\u01a1n gi\u1ea3n l\u00e0 t\u00ean c\u1ee7a m\u1ed9t ph\u01b0\u01a1ng th\u1ee9c \u0111\u01b0\u1ee3c d\u00f9ng trong l\u1ec7nh g\u1eedi tin nh\u1eafn, v\u00ed d\u1ee5: <code>[object doSomething]<\/code>.<\/li>\n\n\n\n<li><strong>Khi bi\u00ean d\u1ecbch<\/strong>: Selector tr\u1edf th\u00e0nh m\u1ed9t \u0111\u1ecbnh danh duy nh\u1ea5t (ki\u1ec3u SEL) \u0111\u1ea1i di\u1ec7n cho t\u00ean ph\u01b0\u01a1ng th\u1ee9c \u0111\u00f3. T\u1ea5t c\u1ea3 c\u00e1c ph\u01b0\u01a1ng th\u1ee9c c\u00f3 c\u00f9ng t\u00ean s\u1ebd chia s\u1ebb c\u00f9ng m\u1ed9t selector.<\/li>\n<\/ul>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"h-objective-c-x\u1eed-ly-ngo\u1ea1i-l\u1ec7-nh\u01b0-th\u1ebf-nao\"><strong>Objective-C x\u1eed l\u00fd ngo\u1ea1i l\u1ec7 nh\u01b0 th\u1ebf n\u00e0o?<\/strong><\/h3>\n\n\n\n<p>Objective-C c\u00f3 2 ki\u1ec3u ch\u00ednh \u0111\u1ec3 x\u1eed l\u00fd exception ph\u1ed5 bi\u1ebfn:<\/p>\n\n\n\n<p>C\u00e1ch th\u1ee9 1 l\u00e0 d\u00f9ng c\u00e1c kh\u1ed1i l\u1ec7nh <code>@try<\/code>, <code>@catch<\/code>, <code>@finally<\/code> v\u00e0 t\u1eeb kh\u00f3a <code>@throw<\/code>.<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong><code>@try<\/code><\/strong>: \u0110\u00e2y l\u00e0 kh\u1ed1i ch\u1ee9a \u0111o\u1ea1n code c\u00f3 th\u1ec3 ph\u00e1t sinh l\u1ed7i (ngo\u1ea1i l\u1ec7). N\u1ebfu l\u1ed7i xu\u1ea5t hi\u1ec7n trong kh\u1ed1i n\u00e0y, qu\u00e1 tr\u00ecnh th\u1ef1c thi s\u1ebd chuy\u1ec3n sang <code>@catch<\/code>.<\/li>\n\n\n\n<li><strong><code>@catch<\/code><\/strong>: Kh\u1ed1i n\u00e0y \u0111\u01b0\u1ee3c d\u00f9ng \u0111\u1ec3 x\u1eed l\u00fd ngo\u1ea1i l\u1ec7. C\u00f3 th\u1ec3 khai b\u00e1o nhi\u1ec1u kh\u1ed1i <code>@catch<\/code> \u0111\u1ec3 x\u1eed l\u00fd c\u00e1c lo\u1ea1i l\u1ed7i kh\u00e1c nhau, tu\u1ef3 theo ki\u1ec3u ngo\u1ea1i l\u1ec7 ph\u00e1t sinh.<\/li>\n\n\n\n<li><strong><code>@finally<\/code><\/strong>: D\u00f9 c\u00f3 l\u1ed7i hay kh\u00f4ng th\u00ec kh\u1ed1i <code>@finally<\/code> v\u1eabn \u0111\u01b0\u1ee3c th\u1ef1c thi. Kh\u1ed1i n\u00e0y th\u01b0\u1eddng \u0111\u01b0\u1ee3c d\u00f9ng \u0111\u1ec3 gi\u1ea3i ph\u00f3ng t\u00e0i nguy\u00ean, \u0111\u00f3ng file ho\u1eb7c th\u1ef1c hi\u1ec7n c\u00e1c b\u01b0\u1edbc d\u1ecdn d\u1eb9p c\u1ea7n thi\u1ebft.<\/li>\n\n\n\n<li><strong><code>@throw<\/code><\/strong>: D\u00f9ng \u0111\u1ec3 n\u00e9m m\u1ed9t ngo\u1ea1i l\u1ec7, th\u01b0\u1eddng l\u00e0 \u0111\u1ed1i t\u01b0\u1ee3ng thu\u1ed9c l\u1edbp NSException ho\u1eb7c l\u1edbp con.<\/li>\n<\/ul>\n\n\n\n<p>C\u00e1ch th\u1ee9 2 l\u00e0 s\u1eed d\u1ee5ng c\u00e1c h\u1ec7 th\u1ed1ng c\u00f3 s\u1eb5n \u0111\u01b0\u1ee3c cung c\u1ea5p trong Objective-C d\u1ef1a tr\u00ean l\u1edbp NSException, v\u1edbi m\u1ed9t s\u1ed1 lo\u1ea1i ph\u1ed5 bi\u1ebfn nh\u01b0 NSRangeException, NSInvalidArgumentException,&#8230;<\/p>\n\n\n\n<p>Ngo\u00e0i ra, l\u1eadp tr\u00ecnh vi\u00ean c\u0169ng c\u00f3 th\u1ec3 t\u1ea1o ngo\u1ea1i l\u1ec7 tu\u1ef3 ch\u1ec9nh n\u1ebfu c\u1ea7n. Tuy nhi\u00ean trong th\u1ef1c t\u1ebf, Objective-C th\u01b0\u1eddng s\u1eed d\u1ee5ng c\u01a1 ch\u1ebf x\u1eed l\u00fd l\u1ed7i b\u1eb1ng NSError h\u01a1n l\u00e0 d\u00f9ng ngo\u1ea1i l\u1ec7, \u0111\u1ec3 tr\u00e1nh crash \u1ee9ng d\u1ee5ng.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"h-s\u1ef1-khac-nhau-gi\u1eefa-retain-va-assigned-trong-objective-c-la-gi\"><strong>S\u1ef1 kh\u00e1c nhau gi\u1eefa retain v\u00e0 assigned trong Objective-C l\u00e0 g\u00ec?<\/strong><\/h3>\n\n\n\n<figure class=\"wp-block-table\"><table class=\"has-fixed-layout\"><tbody><tr><td><strong>Thu\u1ed9c t\u00ednh<\/strong><\/td><td><strong>Retain<\/strong><\/td><td><strong>Assign<\/strong><\/td><\/tr><tr><td>\u0110\u1ed1i t\u01b0\u1ee3ng \u00e1p d\u1ee5ng<\/td><td>D\u00f9ng cho c\u00e1c \u0111\u1ed1i t\u01b0\u1ee3ng k\u1ebf th\u1eeba t\u1eeb NSObject<\/td><td>D\u00f9ng cho ki\u1ec3u d\u1eef li\u1ec7u nguy\u00ean th\u1ee7y (int, BOOL, float, struct,&#8230;)&nbsp;<\/td><\/tr><tr><td>C\u00e1ch ho\u1ea1t \u0111\u1ed9ng<\/td><td>Setter s\u1ebd \u201cretain\u201d gi\u00e1 tr\u1ecb m\u1edbi v\u00e0 \u201crelease\u201d gi\u00e1 tr\u1ecb c\u0169<\/td><td>Setter ch\u1ec9 g\u00e1n gi\u00e1 tr\u1ecb, kh\u00f4ng gi\u1eef l\u1ea1i<\/td><\/tr><tr><td>Qu\u1ea3n l\u00fd b\u1ed9 nh\u1edb<\/td><td>T\u0103ng retain count nh\u1eb1m \u0111\u1ea3m b\u1ea3o \u0111\u1ed1i t\u01b0\u1ee3ng m\u1edbi kh\u00f4ng b\u1ecb gi\u1ea3i ph\u00f3ng s\u1edbm<\/td><td>Kh\u00f4ng \u1ea3nh h\u01b0\u1edfng \u0111\u1ebfn retain count,&nbsp; b\u1ed9 nh\u1edb do n\u01a1i kh\u00e1c qu\u1ea3n l\u00fd&nbsp;<\/td><\/tr><tr><td>R\u1ee7i ro khi d\u00f9ng sai<\/td><td>C\u00f3 th\u1ec3 g\u00e2y retain cycle ho\u1eb7c memory leak<\/td><td>N\u1ebfu g\u00e1n \u0111\u1ed1i t\u01b0\u1ee3ng, c\u00f3 th\u1ec3 d\u1eabn \u0111\u1ebfn dangling pointer khi \u0111\u1ed1i t\u01b0\u1ee3ng b\u1ecb gi\u1ea3i ph\u00f3ng<\/td><\/tr><tr><td>T\u00ednh ch\u1ea5t<\/td><td>Gi\u1eef quy\u1ec1n s\u1edf h\u1eefu \u0111\u1ed1i t\u01b0\u1ee3ng \u0111\u01b0\u1ee3c g\u00e1n<\/td><td>Kh\u00f4ng gi\u1eef quy\u1ec1n s\u1edf h\u1eefu<\/td><\/tr><\/tbody><\/table><\/figure>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"h-khi-nao-c\u1ea7n-s\u1eed-d\u1ee5ng-nsarray-va-nsmutablearray\"><strong>Khi n\u00e0o c\u1ea7n s\u1eed d\u1ee5ng NSArray v\u00e0 NSMutableArray?<\/strong><\/h3>\n\n\n\n<p><strong>NSArray l\u00e0 m\u1ea3ng kh\u00f4ng thay \u0111\u1ed5i (immutable)<\/strong> th\u01b0\u1eddng \u0111\u01b0\u1ee3c d\u00f9ng khi c\u1ea7n m\u1ed9t t\u1eadp h\u1ee3p d\u1eef li\u1ec7u c\u1ed1 \u0111\u1ecbnh, kh\u00f4ng thay \u0111\u1ed5i trong su\u1ed1t qu\u00e1 tr\u00ecnh ch\u1ea1y ch\u01b0\u01a1ng tr\u00ecnh. Sau khi kh\u1edfi t\u1ea1o, kh\u00f4ng th\u1ec3 th\u00eam, xo\u00e1 hay ch\u1ec9nh s\u1eeda ph\u1ea7n t\u1eed. NSArray th\u00edch h\u1ee3p cho: D\u1eef li\u1ec7u c\u1ea5u h\u00ecnh; Danh s\u00e1ch tham chi\u1ebfu; C\u00e1c gi\u00e1 tr\u1ecb h\u1eb1ng s\u1ed1.<\/p>\n\n\n\n<p><strong>NSMutableArray l\u00e0 m\u1ea3ng c\u00f3 th\u1ec3 thay \u0111\u1ed5i (mutable) <\/strong>th\u01b0\u1eddng \u0111\u01b0\u1ee3c d\u00f9ng khi c\u1ea7n m\u1ed9t danh s\u00e1ch linh ho\u1ea1t, c\u00f3 th\u1ec3 c\u1eadp nh\u1eadt n\u1ed9i dung, th\u00eam, xo\u00e1, s\u1eeda ph\u1ea7n t\u1eed b\u1ea5t k\u1ef3 th\u1eddi \u0111i\u1ec3m. NSMutableArray th\u00edch h\u1ee3p cho: D\u1eef li\u1ec7u nh\u1eadp t\u1eeb ng\u01b0\u1eddi d\u00f9ng; Danh s\u00e1ch nh\u1eadn t\u1eeb server; C\u00e1c t\u00ecnh hu\u1ed1ng c\u1ea7n thao t\u00e1c th\u01b0\u1eddng xuy\u00ean tr\u00ean m\u1ea3ng.<\/p>\n\n\n\n<p><strong>Nh\u00ecn chung: <\/strong>NSArray an to\u00e0n cho vi\u1ec7c \u0111\u1ecdc \u0111a lu\u1ed3ng v\u00e0 \u0111\u01b0\u1ee3c \u01b0u ti\u00ean khi ph\u01a1i b\u00e0y d\u1eef li\u1ec7u ra b\u00ean ngo\u00e0i. Trong khi \u0111\u00f3, NSMutableArray linh ho\u1ea1t nh\u01b0ng \u0111\u00f2i h\u1ecfi ph\u1ea3i c\u00f3 c\u01a1 ch\u1ebf \u0111\u1ed3ng b\u1ed9 h\u00f3a c\u1ea9n th\u1eadn n\u1ebfu d\u00f9ng trong m\u00f4i tr\u01b0\u1eddng \u0111a lu\u1ed3ng<\/p>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"h-lam-th\u1ebf-nao-d\u1ec3-t\u1ea1o-m\u1ed9t-ph\u01b0\u01a1ng-th\u1ee9c-tinh-static-method\"><strong>L\u00e0m th\u1ebf n\u00e0o \u0111\u1ec3 t\u1ea1o m\u1ed9t ph\u01b0\u01a1ng th\u1ee9c t\u0129nh (static method)?<\/strong><\/h3>\n\n\n\n<p>\u0110\u1ec3 khai b\u00e1o m\u1ed9t ph\u01b0\u01a1ng th\u1ee9c t\u0129nh, c\u00f3 th\u1ec3 d\u00f9ng t\u1eeb kh\u00f3a <strong><code>static<\/code><\/strong>. Sau \u0111\u00f3 g\u1ecdi qua t\u00ean l\u1edbp m\u00e0 kh\u00f4ng c\u1ea7n t\u1ea1o \u0111\u1ed1i t\u01b0\u1ee3ng. V\u00ed d\u1ee5:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>public class Example {\n    public static void myStaticMethod() {\n        System.out.println(\"Hello from static method!\");\n    }\n}<\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"h-tim-l\u1ed7i-trong-do\u1ea1n-ma-sau\"><strong>T\u00ecm l\u1ed7i trong \u0111o\u1ea1n m\u00e3 sau<\/strong><\/h3>\n\n\n\n<pre class=\"wp-block-code\"><code>SMutableDictionary *dict = &#91;&#91;NSMutableDictionary alloc] init];\n&#91;dict setValue:@\"value\" forKey:nil];<\/code><\/pre>\n\n\n\n<p>\u0110o\u1ea1n code n\u00e0y s\u1ebd g\u00e2y ra l\u1ed7i (ngo\u1ea1i l\u1ec7) v\u00ec key kh\u00f4ng \u0111\u01b0\u1ee3c ph\u00e9p l\u00e0 nil trong m\u1ed9t dictionary. \u0110\u1ec3 kh\u1eafc ph\u1ee5c, c\u1ea7n \u0111i\u1ec1u ch\u1ec9nh key l\u00e0 m\u1ed9t \u0111\u1ed1i t\u01b0\u1ee3ng h\u1ee3p l\u1ec7 v\u00e0 kh\u00f4ng ph\u1ea3i nil.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"h-b\u1ea1n-hi\u1ec3u-th\u1ebf-nao-v\u1ec1-cach-th\u1ee9c-ho\u1ea1t-d\u1ed9ng-c\u1ee7a-synthesize-trong-do\u1ea1n-code-sau\"><strong>B\u1ea1n hi\u1ec3u th\u1ebf n\u00e0o v\u1ec1 c\u00e1ch th\u1ee9c ho\u1ea1t \u0111\u1ed9ng c\u1ee7a @synthesize trong \u0111o\u1ea1n code sau:<\/strong><\/h3>\n\n\n\n<pre class=\"wp-block-code\"><code>@interface MyClass : NSObject\n@property (strong, nonatomic) NSString *name;\n@end\n@implementation MyClass\n@synthesize name = _name;\n@end<\/code><\/pre>\n\n\n\n<p>Trong \u0111o\u1ea1n m\u00e3 tr\u00ean, <code>@synthesize name = _name;<\/code> s\u1ebd t\u1ef1 \u0111\u1ed9ng t\u1ea1o ra ph\u01b0\u01a1ng th\u1ee9c <code>getter -name<\/code> v\u00e0 <code>setter -setName:<\/code> cho thu\u1ed9c t\u00ednh name, \u0111\u1ed3ng th\u1eddi s\u1eed d\u1ee5ng bi\u1ebfn <code>instance _name<\/code> \u0111\u1ec3 l\u01b0u gi\u00e1 tr\u1ecb.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"h-kh\u1ed1i-block-trong-objective-c-la-gi-va-no-khac-v\u1edbi-closure-trong-cac-ngon-ng\u1eef-l\u1eadp-trinh-khac-nh\u01b0-th\u1ebf-nao\"><strong>Kh\u1ed1i (block) trong Objective-C l\u00e0 g\u00ec v\u00e0 n\u00f3 kh\u00e1c v\u1edbi closure trong c\u00e1c ng\u00f4n ng\u1eef l\u1eadp tr\u00ecnh kh\u00e1c nh\u01b0 th\u1ebf n\u00e0o?<\/strong><\/h3>\n\n\n\n<figure class=\"wp-block-table\"><table class=\"has-fixed-layout\"><tbody><tr><td><strong>Ti\u00eau ch\u00ed<\/strong><\/td><td><strong>Kh\u1ed1i trong Objective-C<\/strong><\/td><td><strong>Closure trong Swift&nbsp;<\/strong><\/td><\/tr><tr><td><strong>\u0110\u1ecbnh ngh\u0129a<\/strong><\/td><td>\u0110o\u1ea1n m\u00e3 c\u00f3 th\u1ec3 \u0111\u01b0\u1ee3c l\u01b0u tr\u1eef v\u00e0 th\u1ef1c thi sau; c\u00f3 th\u1ec3 capture bi\u1ebfn c\u1ee5c b\u1ed9<\/td><td>H\u00e0m \u1ea9n danh (anonymous function) c\u00f3 th\u1ec3 capture v\u00e0 s\u1eed d\u1ee5ng bi\u1ebfn b\u00ean ngo\u00e0i ph\u1ea1m vi khai b\u00e1o<\/td><\/tr><tr><td><strong>Kh\u1ea3 n\u0103ng capture bi\u1ebfn<\/strong><\/td><td>C\u1ea7n khai b\u00e1o bi\u1ebfn v\u1edbi block n\u1ebfu mu\u1ed1n s\u1eeda \u0111\u1ed5i<\/td><td>C\u00f3 th\u1ec3 s\u1eeda \u0111\u1ed5i tr\u1ef1c ti\u1ebfp (kh\u00f4ng c\u1ea7n t\u1eeb kh\u00f3a \u0111\u1eb7c bi\u1ec7t)&nbsp;<\/td><\/tr><tr><td><strong>C\u00fa ph\u00e1p<\/strong><\/td><td>D\u00e0i d\u00f2ng, k\u1ebf th\u1eeba t\u1eeb C, kh\u00f3 \u0111\u1ecdc v\u1edbi ng\u01b0\u1eddi m\u1edbi b\u1eaft \u0111\u1ea7u<\/td><td>Ng\u1eafn g\u1ecdn, r\u00f5 r\u00e0ng v\u00e0 d\u1ec5 vi\u1ebft h\u01a1n<\/td><\/tr><tr><td><strong>Qu\u1ea3n l\u00fd b\u1ed9 nh\u1edb<\/strong><\/td><td>D\u1ec5 g\u00e2y retain cycle n\u1ebfu kh\u00f4ng d\u00f9ng \u0111\u00fang weak ho\u1eb7c strong, c\u1ea7n copy block th\u1ee7 c\u00f4ng trong 1 s\u1ed1 tr\u01b0\u1eddng h\u1ee3p<\/td><td>Swift d\u00f9ng ARC, x\u1eed l\u00fd retain cycle \u0111\u01a1n gi\u1ea3n h\u01a1n<\/td><\/tr><tr><td><strong>Kh\u1ea3 n\u0103ng s\u1eed d\u1ee5ng l\u00e2u d\u00e0i<\/strong><\/td><td>Ph\u1ea3i d\u00f9ng copy n\u1ebfu mu\u1ed1n block t\u1ed3n t\u1ea1i tr\u00ean heap<\/td><td>Kh\u00f4ng c\u1ea7n thao t\u00e1c th\u00eam v\u00ec closures \u0111\u01b0\u1ee3c qu\u1ea3n l\u00fd t\u1ef1 \u0111\u1ed9ng<\/td><\/tr><tr><td><strong>\u1ee8ng d\u1ee5ng ph\u1ed5 bi\u1ebfn<\/strong><\/td><td>Callbacks, animation, completion handlers trong Cocoa \/ UIKit<\/td><td>Event handlers, async code, functional programming<\/td><\/tr><\/tbody><\/table><\/figure>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"h-neu-hi\u1ec3u-bi\u1ebft-c\u1ee7a-b\u1ea1n-v\u1ec1-kvo-key-value-observing-trong-objective-c\"><strong>N\u00eau hi\u1ec3u bi\u1ebft c\u1ee7a b\u1ea1n v\u1ec1 KVO (Key-Value Observing) trong Objective C<\/strong><\/h3>\n\n\n\n<p>KVO (Key-Value Observing) trong Objective-C l\u00e0 c\u01a1 ch\u1ebf cho ph\u00e9p m\u1ed9t \u0111\u1ed1i t\u01b0\u1ee3ng theo d\u00f5i s\u1ef1 thay \u0111\u1ed5i gi\u00e1 tr\u1ecb c\u1ee7a m\u1ed9t thu\u1ed9c t\u00ednh tr\u00ean \u0111\u1ed1i t\u01b0\u1ee3ng kh\u00e1c. Khi thu\u1ed9c t\u00ednh \u0111\u01b0\u1ee3c quan s\u00e1t thay \u0111\u1ed5i, h\u1ec7 th\u1ed1ng s\u1ebd t\u1ef1 \u0111\u1ed9ng th\u00f4ng b\u00e1o cho observer. KVO th\u01b0\u1eddng d\u00f9ng \u0111\u1ec3 t\u00e1ch bi\u1ec7t logic theo d\u00f5i tr\u1ea1ng th\u00e1i, thu\u1eadn ti\u1ec7n trong c\u00e1c m\u00f4 h\u00ecnh nh\u01b0 MVC.&nbsp;<\/p>\n\n\n\n<p>Vi\u1ec7c s\u1eed d\u1ee5ng KVO y\u00eau c\u1ea7u g\u1ecdi <code>addObserver:forKeyPath:options:context:<\/code> \u0111\u1ec3 \u0111\u0103ng k\u00fd v\u00e0 override <code>observeValueForKeyPath:ofObject:change:context:<\/code> \u0111\u1ec3 x\u1eed l\u00fd thay \u0111\u1ed5i. Sau khi kh\u00f4ng d\u00f9ng n\u1eefa, c\u1ea7n g\u1ecdi <code>removeObserver:<\/code> \u0111\u1ec3 tr\u00e1nh crash.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"h-ph\u01b0\u01a1ng-th\u1ee9c-dealloc-la-gi-gi\u1ea3i-thich-y-nghia-c\u1ee7a-ph\u01b0\u01a1ng-th\u1ee9c-nay-trong-do\u1ea1n-ma-sau\"><strong>Ph\u01b0\u01a1ng th\u1ee9c dealloc l\u00e0 g\u00ec? Gi\u1ea3i th\u00edch \u00fd ngh\u0129a c\u1ee7a ph\u01b0\u01a1ng th\u1ee9c n\u00e0y trong \u0111o\u1ea1n m\u00e3 sau:<\/strong><\/h3>\n\n\n\n<pre class=\"wp-block-code\"><code>@interface MyClass : NSObject\n@property (nonatomic, strong) NSString *name;\n@end\n@implementation MyClass\n- (void)dealloc {\n    NSLog(@\"MyClass instance with name %@ is being deallocated.\", self.name);\n    &#91;super dealloc];\n}\n@end<\/code><\/pre>\n\n\n\n<p>Ph\u01b0\u01a1ng th\u1ee9c dealloc trong Objective-C \u0111\u01b0\u1ee3c s\u1eed d\u1ee5ng \u0111\u1ec3 gi\u1ea3i ph\u00f3ng t\u00e0i nguy\u00ean m\u00e0 \u0111\u1ed1i t\u01b0\u1ee3ng \u0111ang gi\u1eef tr\u01b0\u1edbc khi b\u1ecb h\u1ec7 th\u1ed1ng thu h\u1ed3i b\u1ed9 nh\u1edb. \u0110\u00e2y l\u00e0 n\u01a1i l\u1eadp tr\u00ecnh vi\u00ean th\u1ef1c hi\u1ec7n c\u00e1c thao t\u00e1c d\u1ecdn d\u1eb9p nh\u01b0 gi\u1ea3i ph\u00f3ng b\u1ed9 nh\u1edb, \u0111\u00f3ng c\u00e1c file \u0111ang m\u1edf ho\u1eb7c hu\u1ef7 \u0111\u0103ng k\u00fd c\u00e1c observer \u0111\u00e3 \u0111\u01b0\u1ee3c thi\u1ebft l\u1eadp trong su\u1ed1t v\u00f2ng \u0111\u1eddi c\u1ee7a \u0111\u1ed1i t\u01b0\u1ee3ng.&nbsp;<\/p>\n\n\n\n<p>Trong \u0111o\u1ea1n m\u00e3 tr\u00ean, ph\u01b0\u01a1ng th\u1ee9c dealloc s\u1ebd in ra th\u00f4ng b\u00e1o khi m\u1ed9t instance c\u1ee7a l\u1edbp MyClass b\u1ecb thu h\u1ed3i. \u0110\u1ed3ng th\u1eddi, cho bi\u1ebft gi\u00e1 tr\u1ecb thu\u1ed9c t\u00ednh name c\u1ee7a \u0111\u1ed1i t\u01b0\u1ee3ng \u0111ang \u0111\u01b0\u1ee3c d\u1ecdn d\u1eb9p. L\u1ec7nh g\u1ecdi <code>[super dealloc]<\/code> \u0111\u1ea3m b\u1ea3o qu\u00e1 tr\u00ecnh d\u1ecdn d\u1eb9p \u0111\u01b0\u1ee3c th\u1ef1c hi\u1ec7n \u0111\u1ea7y \u0111\u1ee7 b\u1eb1ng c\u00e1ch g\u1ecdi ph\u01b0\u01a1ng th\u1ee9c dealloc c\u1ee7a l\u1edbp cha.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"h-output-c\u1ee7a-do\u1ea1n-ma-sau-s\u1ebd-la-gi\"><strong>Output c\u1ee7a \u0111o\u1ea1n m\u00e3 sau s\u1ebd l\u00e0 g\u00ec?<\/strong><\/h3>\n\n\n\n<pre class=\"wp-block-code\"><code>NSArray *array = @&#91;@1, @2, @3]; \nNSLog(@\"%@\", &#91;array objectAtIndex:1]);<\/code><\/pre>\n\n\n\n<p>Output l\u00e0 2. Ph\u01b0\u01a1ng th\u1ee9c <code>objectAtIndex<\/code> d\u00f9ng \u0111\u1ec3 truy xu\u1ea5t \u0111\u1ed1i t\u01b0\u1ee3ng \u1edf v\u1ecb tr\u00ed ch\u1ec9 \u0111\u1ecbnh trong m\u1ea3ng. Index c\u1ee7a m\u1ea3ng trong Objective C b\u1eaft \u0111\u1ea7u t\u1eeb 0 n\u00ean khi set <code>objectAtindex == 1<\/code> th\u00ec k\u1ebft qu\u1ea3 s\u1ebd l\u00e0 2.&nbsp;<\/p>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"h-do\u1ea1n-ma-sau-s\u1ebd-cho-k\u1ebft-qu\u1ea3-gi\"><strong>\u0110o\u1ea1n m\u00e3 sau s\u1ebd cho k\u1ebft qu\u1ea3 g\u00ec?<\/strong><\/h3>\n\n\n\n<pre class=\"wp-block-code\"><code>@interface MyClass: NSObject \n@property (nonatomic, strong) NSString *text; \n@end \n@implementation MyClass \n@synthesize text; \n- (void)dealloc { \n    NSLog(@\"Deallocating %@\", &#91;self.text uppercaseString]); \n} \n@end \nint main() { \n    MyClass *obj = &#91;&#91;MyClass alloc] init]; \n    obj.text = @\"hello\"; \n    obj = nil; \n    return 0; \n}<\/code><\/pre>\n\n\n\n<p>K\u1ebft qu\u1ea3 c\u1ee7a \u0111o\u1ea1n code tr\u00ean s\u1ebd l\u00e0 \u201cDeallocating HELLO\u201d. Ph\u01b0\u01a1ng th\u1ee9c <code>dealloc<\/code> s\u1ebd ghi log chu\u1ed7i k\u00fd t\u1ef1 vi\u1ebft hoa c\u1ee7a thu\u1ed9c t\u00ednh text.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"h-cau-h\u1ecfi-ph\u1ecfng-v\u1ea5n-objective-c-c\u1ea5p-d\u1ed9-cao-senior-level\"><span class=\"ez-toc-section\" id=\"Cau_hoi_phong_van_Objective-C_cap_do_cao_Senior_Level\"><\/span><strong>C\u00e2u h\u1ecfi ph\u1ecfng v\u1ea5n Objective-C c\u1ea5p \u0111\u1ed9 cao (Senior Level)<\/strong><span class=\"ez-toc-section-end\"><\/span><\/h2>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"h-s\u1ef1-khac-bi\u1ec7t-gi\u1eefa-ham-function-va-th\u1ee7-t\u1ee5c-procedure-d\u01b0\u1ee3c-l\u01b0u-tr\u1eef-trong-net-la-gi\"><strong>S\u1ef1 kh\u00e1c bi\u1ec7t gi\u1eefa h\u00e0m (Function) v\u00e0 th\u1ee7 t\u1ee5c (Procedure) \u0111\u01b0\u1ee3c l\u01b0u tr\u1eef trong .NET l\u00e0 g\u00ec?&nbsp;<\/strong><\/h3>\n\n\n\n<figure class=\"wp-block-table\"><table class=\"has-fixed-layout\"><tbody><tr><td><strong>H\u00e0m<\/strong><\/td><td><strong>Th\u1ee7 t\u1ee5c&nbsp;<\/strong><\/td><\/tr><tr><td>Lu\u00f4n tr\u1ea3 v\u1ec1 m\u1ed9t gi\u00e1 tr\u1ecb sau khi th\u1ef1c thi c\u00e2u l\u1ec7nh<\/td><td>C\u00f3 th\u1ec3 tr\u1ea3 v\u1ec1 gi\u00e1 tr\u1ecb th\u00f4ng qua tham s\u1ed1 IN OUT v\u00e0 OUT<\/td><\/tr><tr><td>H\u00e0m c\u00f3 ch\u1ee9a c\u00e2u l\u1ec7nh DML (INSERT, UPDATE, DELETE) kh\u00f4ng th\u1ec3 \u0111\u01b0\u1ee3c g\u1ecdi t\u1eeb truy v\u1ea5n SQL.&nbsp;H\u00e0m giao d\u1ecbch \u0111\u1ed9c l\u1eadp (autonomous transaction functions) c\u00f3 th\u1ec3 \u0111\u01b0\u1ee3c g\u1ecdi t\u1eeb truy v\u1ea5n SQL.<\/td><td>Kh\u00f4ng th\u1ec3 \u0111\u01b0\u1ee3c g\u1ecdi tr\u1ef1c ti\u1ebfp t\u1eeb c\u00e2u l\u1ec7nh SQL.<\/td><\/tr><tr><td>M\u1ed7i l\u1ea7n bi\u00ean d\u1ecbch h\u00e0m, n\u00f3 s\u1ebd cho ra k\u1ebft qu\u1ea3 d\u1ef1a tr\u00ean \u0111\u1ea7u v\u00e0o<\/td><td>Ch\u1ec9 bi\u00ean d\u1ecbch m\u1ed9t l\u1ea7n v\u00e0 c\u00f3 th\u1ec3 \u0111\u01b0\u1ee3c g\u1ecdi l\u1ea1i nhi\u1ec1u l\u1ea7n m\u00e0 kh\u00f4ng c\u1ea7n bi\u00ean d\u1ecbch l\u1ea1i.<\/td><\/tr><tr><td>Kh\u00f4ng th\u1ec3 tr\u1ea3 v\u1ec1 nhi\u1ec1u t\u1eadp k\u1ebft qu\u1ea3.<\/td><td>C\u00f3 th\u1ec3 tr\u1ea3 v\u1ec1 nhi\u1ec1u t\u1eadp k\u1ebft qu\u1ea3.<\/td><\/tr><tr><td>C\u00f3 th\u1ec3 \u0111\u01b0\u1ee3c g\u1ecdi t\u1eeb th\u1ee7 t\u1ee5c l\u01b0u tr\u1eef.<\/td><td>Kh\u00f4ng th\u1ec3 \u0111\u01b0\u1ee3c g\u1ecdi t\u1eeb h\u00e0m.<\/td><\/tr><tr><td>Ch\u1ec9 d\u00f9ng \u0111\u1ec3 \u0111\u1ecdc d\u1eef li\u1ec7u.<\/td><td>C\u00f3 th\u1ec3 d\u00f9ng \u0111\u1ec3 \u0111\u1ecdc v\u00e0 ch\u1ec9nh s\u1eeda d\u1eef li\u1ec7u<\/td><\/tr><tr><td>L\u1ec7nh RETURN c\u1ee7a h\u00e0m tr\u1ea3 v\u1ec1 \u0111i\u1ec1u khi\u1ec3n c\u00f9ng v\u1edbi gi\u00e1 tr\u1ecb c\u1ee7a h\u00e0m cho ch\u01b0\u01a1ng tr\u00ecnh g\u1ecdi.<\/td><td>L\u1ec7nh RETURN c\u1ee7a th\u1ee7 t\u1ee5c ch\u1ec9 tr\u1ea3 v\u1ec1 \u0111i\u1ec1u khi\u1ec3n, kh\u00f4ng tr\u1ea3 v\u1ec1 gi\u00e1 tr\u1ecb.<\/td><\/tr><tr><td>Kh\u00f4ng h\u1ed7 tr\u1ee3 kh\u1ed1i try-catch.<\/td><td>H\u1ed7 tr\u1ee3 try-catch \u0111\u1ec3 x\u1eed l\u00fd l\u1ed7i.<\/td><\/tr><tr><td>C\u00f3 th\u1ec3 \u0111\u01b0\u1ee3c s\u1eed d\u1ee5ng trong c\u00e2u l\u1ec7nh SELECT<\/td><td>Kh\u00f4ng th\u1ec3 s\u1eed d\u1ee5ng trong c\u00e2u l\u1ec7nh SELECT.<\/td><\/tr><tr><td>Kh\u00f4ng h\u1ed7 tr\u1ee3 qu\u1ea3n l\u00fd giao d\u1ecbch.<\/td><td>H\u1ed7 tr\u1ee3 qu\u1ea3n l\u00fd giao d\u1ecbch.<\/td><\/tr><tr><td>Ch\u1ec9 c\u00f3 th\u1ec3 s\u1eed d\u1ee5ng bi\u1ebfn b\u1ea3ng (table variable)<\/td><td>C\u00f3 th\u1ec3 s\u1eed d\u1ee5ng c\u1ea3 b\u1ea3ng t\u1ea1m v\u00e0 bi\u1ebfn b\u1ea3ng \u0111\u1ec3 l\u01b0u d\u1eef li\u1ec7u t\u1ea1m th\u1eddi.<\/td><\/tr><\/tbody><\/table><\/figure>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"h-gi\u1ea3i-thich-cac-lo\u1ea1i-giao-th\u1ee9c-protocol-trong-objective-c\"><strong>Gi\u1ea3i th\u00edch c\u00e1c lo\u1ea1i giao th\u1ee9c (protocol) trong Objective-C?<\/strong><\/h3>\n\n\n\n<p>Trong Objective-C, giao th\u1ee9c l\u00e0 m\u1ed9t t\u1eadp h\u1ee3p c\u00e1c ph\u01b0\u01a1ng th\u1ee9c m\u00e0 c\u00e1c l\u1edbp c\u00f3 th\u1ec3 tu\u00e2n th\u1ee7 (conform) \u0111\u1ec3 th\u1ef1c thi nh\u1eefng ch\u1ee9c n\u0103ng nh\u1ea5t \u0111\u1ecbnh. C\u00f3 hai lo\u1ea1i giao th\u1ee9c ch\u00ednh \u0111\u01b0\u1ee3c s\u1eed d\u1ee5ng ph\u1ed5 bi\u1ebfn: giao th\u1ee9c ch\u00ednh th\u1ee9c (Formal Protocol) v\u00e0 giao th\u1ee9c kh\u00f4ng ch\u00ednh th\u1ee9c (Informal Protocol).<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong>Giao th\u1ee9c ch\u00ednh th\u1ee9c (Formal Protocol): <\/strong>\u0110\u00e2y l\u00e0 giao th\u1ee9c \u0111\u01b0\u1ee3c \u0111\u1ecbnh danh r\u00f5 r\u00e0ng, c\u00f3 t\u00ean v\u00e0 \u0111\u01b0\u1ee3c bi\u00ean d\u1ecbch tr\u1ef1c ti\u1ebfp trong Objective-C. Giao th\u1ee9c ch\u00ednh th\u1ee9c \u0111\u01b0\u1ee3c s\u1eed d\u1ee5ng r\u1ed9ng r\u00e3i trong vi\u1ec7c giao ti\u1ebfp v\u00e0 trao \u0111\u1ed5i d\u1eef li\u1ec7u gi\u1eefa c\u00e1c \u0111\u1ed1i t\u01b0\u1ee3ng kh\u00e1c nhau.<\/li>\n\n\n\n<li><strong>Giao th\u1ee9c kh\u00f4ng ch\u00ednh th\u1ee9c (Informal Protocol): <\/strong>\u0110\u01b0\u1ee3c tri\u1ec3n khai th\u00f4ng qua category (danh m\u1ee5c m\u1edf r\u1ed9ng) thay v\u00ec khai b\u00e1o ch\u00ednh th\u1ee9c b\u1eb1ng t\u1eeb kh\u00f3a @protocol. C\u00e1c ph\u01b0\u01a1ng th\u1ee9c trong giao th\u1ee9c n\u00e0y kh\u00f4ng b\u1eaft bu\u1ed9c ph\u1ea3i \u0111\u01b0\u1ee3c c\u00e1c l\u1edbp tri\u1ec3n khai, mang t\u00ednh ch\u1ea5t m\u1edf r\u1ed9ng t\u00f9y ch\u1ecdn.<\/li>\n<\/ul>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"h-gi\u1ea3i-thich-cach-s\u1eed-d\u1ee5ng-cac-danh-m\u1ee5c-category-trong-objective-c-d\u1ec3-m\u1edf-r\u1ed9ng-ch\u1ee9c-nang-c\u1ee7a-cac-l\u1edbp-hi\u1ec7n-co\"><strong>Gi\u1ea3i th\u00edch c\u00e1ch s\u1eed d\u1ee5ng c\u00e1c danh m\u1ee5c (category) trong Objective-C \u0111\u1ec3 m\u1edf r\u1ed9ng ch\u1ee9c n\u0103ng c\u1ee7a c\u00e1c l\u1edbp hi\u1ec7n c\u00f3<\/strong><\/h3>\n\n\n\n<p>Danh m\u1ee5c trong Objective-C l\u00e0 m\u1ed9t c\u01a1 ch\u1ebf cho ph\u00e9p m\u1edf r\u1ed9ng ch\u1ee9c n\u0103ng c\u1ee7a m\u1ed9t l\u1edbp \u0111\u00e3 t\u1ed3n t\u1ea1i m\u00e0 kh\u00f4ng c\u1ea7n ph\u1ea3i s\u1eeda \u0111\u1ed5i tr\u1ef1c ti\u1ebfp m\u00e3 ngu\u1ed3n c\u1ee7a l\u1edbp \u0111\u00f3.<\/p>\n\n\n\n<p>Nh\u1edd c\u00f3 danh m\u1ee5c, l\u1eadp tr\u00ecnh vi\u00ean c\u00f3 th\u1ec3 th\u00eam ph\u01b0\u01a1ng th\u1ee9c m\u1edbi v\u00e0o m\u1ed9t l\u1edbp b\u1ea5t k\u1ef3, k\u1ec3 c\u1ea3 l\u1edbp g\u1ed1c c\u1ee7a iOS nh\u01b0 NSString, NSArray,&#8230; m\u00e0 kh\u00f4ng c\u1ea7n ph\u1ea3i t\u1ea1o l\u1edbp con (subclass) hay thay \u0111\u1ed5i c\u1ea5u tr\u00fac l\u1edbp ban \u0111\u1ea7u.<\/p>\n\n\n\n<p><strong>C\u00fa ph\u00e1p \u0111\u1ecbnh ngh\u0129a m\u1ed9t category:<\/strong><\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>@interface MyClass (MyCategory)\n- (void)newMethod;\n@end<\/code><\/pre>\n\n\n\n<p><strong>C\u00e1ch tri\u1ec3n khai:<\/strong><\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>@implementation MyClass (MyCategory)\n- (void)newMethod {\n    NSLog(@\"New method from category!\");\n}\n@end<\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"h-cac-ki\u1ec3u-id-va-class-c\u1ee7a-objective-c-khac-nhau-nh\u01b0-th\u1ebf-nao-va-khi-nao-b\u1ea1n-s\u1ebd-s\u1eed-d\u1ee5ng-t\u1eebng-ki\u1ec3u\"><strong>C\u00e1c ki\u1ec3u id v\u00e0 Class c\u1ee7a Objective-C kh\u00e1c nhau nh\u01b0 th\u1ebf n\u00e0o v\u00e0 khi n\u00e0o b\u1ea1n s\u1ebd s\u1eed d\u1ee5ng t\u1eebng ki\u1ec3u?<\/strong><\/h3>\n\n\n\n<p>Trong Objective-C, <code>id<\/code> v\u00e0 <code>Class<\/code> l\u00e0 hai ki\u1ec3u d\u1eef li\u1ec7u \u0111\u1eb7c bi\u1ec7t, \u0111\u1ec1u li\u00ean quan \u0111\u1ebfn \u0111\u1ed1i t\u01b0\u1ee3ng, nh\u01b0ng ph\u1ee5c v\u1ee5 nh\u1eefng m\u1ee5c \u0111\u00edch kh\u00e1c nhau.&nbsp;<\/p>\n\n\n\n<figure class=\"wp-block-table\"><table class=\"has-fixed-layout\"><tbody><tr><td><strong>Ti\u00eau ch\u00ed<\/strong><\/td><td><strong>Ki\u1ec3u id<\/strong><\/td><td><strong>Ki\u1ec3u class<\/strong><\/td><\/tr><tr><td><strong>\u0110\u1ecbnh ngh\u0129a<\/strong><\/td><td>\u0110\u1ea1i di\u1ec7n cho m\u1ed9t con tr\u1ecf \u0111\u1ebfn b\u1ea5t k\u1ef3 \u0111\u1ed1i t\u01b0\u1ee3ng n\u00e0o trong Objective-C<\/td><td>L\u00e0 m\u1ed9t con tr\u1ecf \u0111\u1ebfn l\u1edbp (kh\u00f4ng ph\u1ea3i \u0111\u1ebfn m\u1ed9t instance c\u1ee5 th\u1ec3)<\/td><\/tr><tr><td><strong>Lo\u1ea1i d\u1eef li\u1ec7u<\/strong><\/td><td>\u0110\u1ea1i di\u1ec7n cho instance c\u1ee7a m\u1ed9t l\u1edbp<\/td><td>\u0110\u1ea1i di\u1ec7n cho b\u1ea3n th\u00e2n l\u1edbp \u0111\u00f3&nbsp;<\/td><\/tr><tr><td><strong>Th\u1eddi \u0111i\u1ec3m x\u00e1c \u0111\u1ecbnh ki\u1ec3u<\/strong><\/td><td>Kh\u00f4ng c\u1ea7n ch\u1ec9 r\u00f5 l\u1edbp c\u1ee5 th\u1ec3 c\u1ee7a \u0111\u1ed1i t\u01b0\u1ee3ng t\u1ea1i th\u1eddi \u0111i\u1ec3m bi\u00ean d\u1ecbch<\/td><td>Ph\u1ea3i bi\u1ebft l\u1edbp (ho\u1eb7c lo\u1ea1i) t\u1ea1i th\u1eddi \u0111i\u1ec3m khai b\u00e1o&nbsp;<\/td><\/tr><tr><td><strong>T\u00ednh linh ho\u1ea1t<\/strong><\/td><td>R\u1ea5t linh ho\u1ea1t, c\u00f3 th\u1ec3 d\u00f9ng v\u1edbi b\u1ea5t k\u1ef3 \u0111\u1ed1i t\u01b0\u1ee3ng n\u00e0o<\/td><td>H\u1ea1n ch\u1ebf h\u01a1n, ch\u1ec9 l\u00e0m vi\u1ec7c v\u1edbi l\u1edbp<\/td><\/tr><tr><td><strong>T\u00ecnh hu\u1ed1ng s\u1eed d\u1ee5ng<\/strong><\/td><td>Khi lo\u1ea1i \u0111\u1ed1i t\u01b0\u1ee3ng ch\u01b0a x\u00e1c \u0111\u1ecbnh ho\u1eb7c kh\u00f4ng quan tr\u1ecdng<\/td><td>Khi c\u1ea7n thao t\u00e1c v\u1edbi l\u1edbp, nh\u01b0 t\u1ea1o \u0111\u1ed1i t\u01b0\u1ee3ng b\u1eb1ng alloc, g\u1ecdi class method<\/td><\/tr><tr><td><strong>G\u1ecdi ph\u01b0\u01a1ng th\u1ee9c<\/strong><\/td><td>C\u00f3 th\u1ec3 g\u1ecdi b\u1ea5t k\u1ef3 ph\u01b0\u01a1ng th\u1ee9c n\u00e0o, nh\u01b0ng kh\u00f4ng \u0111\u01b0\u1ee3c ki\u1ec3m tra ki\u1ec3u t\u1ea1i compile-time<\/td><td>D\u00f9ng \u0111\u1ec3 g\u1ecdi class methods (static methods)<\/td><\/tr><\/tbody><\/table><\/figure>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"h-cho-bi\u1ebft-cach-g\u1ecdi-cac-ham-ph\u01b0\u01a1ng-th\u1ee9c-c\u1ee7a-objective-c-m\u1ed9t-cach-b\u1ea5t-d\u1ed3ng-b\u1ed9\"><strong>Cho bi\u1ebft c\u00e1ch g\u1ecdi c\u00e1c h\u00e0m\/ph\u01b0\u01a1ng th\u1ee9c c\u1ee7a Objective-C m\u1ed9t c\u00e1ch b\u1ea5t \u0111\u1ed3ng b\u1ed9?<\/strong><\/h3>\n\n\n\n<p>Trong Objective-C, m\u1ed7i ph\u01b0\u01a1ng th\u1ee9c \u0111\u01b0\u1ee3c nh\u1eadn d\u1ea1ng b\u1eb1ng selector, g\u1ed3m t\u00ean v\u00e0 v\u1ecb tr\u00ed tham s\u1ed1 (d\u1ea5u <code>:<\/code>). Selector trong Objective-C cho ph\u00e9p g\u1ecdi ph\u01b0\u01a1ng th\u1ee9c \u0111\u1ed9ng m\u00e0 kh\u00f4ng c\u1ea7n bi\u1ebft t\u00ean ho\u1eb7c ki\u1ec3u c\u1ee7a ph\u01b0\u01a1ng th\u1ee9c t\u1ea1i th\u1eddi \u0111i\u1ec3m bi\u00ean d\u1ecbch.<\/p>\n\n\n\n<p>\u0110\u1eb7c bi\u1ec7t h\u1eefu \u00edch trong c\u00e1c t\u00ecnh hu\u1ed1ng c\u1ea7n x\u1eed l\u00fd linh ho\u1ea1t, nh\u01b0 khi l\u00e0m vi\u1ec7c v\u1edbi \u0111\u1ed1i t\u01b0\u1ee3ng kh\u00f4ng x\u00e1c \u0111\u1ecbnh ho\u1eb7c t\u1eeb m\u1ed9t c\u1ea5u h\u00ecnh ngo\u00e0i.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"h-m\u1ee5c-dich-c\u1ee7a-implementation-trong-objective-c-la-gi-va-no-lien-quan-nh\u01b0-th\u1ebf-nao-d\u1ebfn-interface\"><strong>M\u1ee5c \u0111\u00edch c\u1ee7a @implementation trong Objective-C l\u00e0 g\u00ec v\u00e0 n\u00f3 li\u00ean quan nh\u01b0 th\u1ebf n\u00e0o \u0111\u1ebfn @interface?<\/strong><\/h3>\n\n\n\n<p>Trong Objective-C, <code>@implementation<\/code> \u0111\u01b0\u1ee3c s\u1eed d\u1ee5ng \u0111\u1ec3 \u0111\u1ecbnh ngh\u0129a ph\u1ea7n c\u00e0i \u0111\u1eb7t th\u1ef1c t\u1ebf cho c\u00e1c ph\u01b0\u01a1ng th\u1ee9c \u0111\u00e3 khai b\u00e1o trong <code>@interface<\/code>. C\u1eb7p ch\u1ec9 th\u1ecb n\u00e0y gi\u00fap t\u00e1ch bi\u1ec7t ph\u1ea7n khai b\u00e1o v\u00e0 ph\u1ea7n \u0111\u1ecbnh ngh\u0129a, l\u00e0m cho m\u00e3 ngu\u1ed3n r\u00f5 r\u00e0ng v\u00e0 d\u1ec5 b\u1ea3o tr\u00ec h\u01a1n.<\/p>\n\n\n\n<p>N\u1ebfu <code>@interface<\/code> \u0111\u00f3ng vai tr\u00f2 nh\u01b0 m\u1ed9t b\u1ea3n thi\u1ebft k\u1ebf, n\u01a1i khai b\u00e1o t\u00ean l\u1edbp, thu\u1ed9c t\u00ednh v\u00e0 c\u00e1c ph\u01b0\u01a1ng th\u1ee9c c\u00f4ng khai, th\u00ec <code>@implementation<\/code> l\u00e0 n\u01a1i hi\u1ec7n th\u1ef1c h\u00f3a b\u1ea3n thi\u1ebft k\u1ebf \u0111\u00f3 b\u1eb1ng c\u00e1ch vi\u1ebft n\u1ed9i dung c\u1ee5 th\u1ec3 cho t\u1eebng ph\u01b0\u01a1ng th\u1ee9c.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"h-hay-gi\u1ea3i-thich-cach-ho\u1ea1t-d\u1ed9ng-c\u1ee7a-printclassmethods-d\u1ec3-ki\u1ec3m-tra-th\u1eddi-gian-ch\u1ea1y-trong-objective-c-t\u1eeb-do\u1ea1n-ma-d\u01b0\u1edbi-day\"><strong>H\u00e3y gi\u1ea3i th\u00edch c\u00e1ch ho\u1ea1t \u0111\u1ed9ng c\u1ee7a PrintClassMethods \u0111\u1ec3 ki\u1ec3m tra th\u1eddi gian ch\u1ea1y trong Objective-C t\u1eeb \u0111o\u1ea1n m\u00e3 d\u01b0\u1edbi \u0111\u00e2y<\/strong><\/h3>\n\n\n\n<pre class=\"wp-block-code\"><code>\u200b\u200b#import \nvoid PrintClassMethods(Class class) {\n    unsigned int methodCount = 0;\n    Method *methods = class_copyMethodList(class, &amp;methodCount);\n    for (unsigned int i = 0; i &lt; methodCount; i++) {\n        Method method = methods&#91;i];\n        SEL selector = method_getName(method);\n        NSLog(@\"Method: %@\", NSStringFromSelector(selector));\n    }\n    free(methods);\n}<\/code><\/pre>\n\n\n\n<p>\u200bTrong \u0111o\u1ea1n code tr\u00ean, <code>PrintClassMethods<\/code> s\u1eed d\u1ee5ng t\u00ednh n\u0103ng runtime introspection \u0111\u1ec3 li\u1ec7t k\u00ea t\u1ea5t c\u1ea3 ph\u01b0\u01a1ng th\u1ee9c c\u1ee7a m\u1ed9t l\u1edbp \u0111\u01b0\u1ee3c ch\u1ec9 \u0111\u1ecbnh. N\u00f3 l\u1ea5y danh s\u00e1ch c\u00e1c ph\u01b0\u01a1ng th\u1ee9c v\u00e0 selector, cho ph\u00e9p l\u1eadp tr\u00ecnh vi\u00ean ki\u1ec3m tra v\u00e0 t\u01b0\u01a1ng t\u00e1c \u0111\u1ed9ng v\u1edbi c\u00e1c ph\u01b0\u01a1ng th\u1ee9c c\u1ee7a l\u1edbp t\u1ea1i th\u1eddi gian ch\u1ea1y.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"h-gi\u1ea3i-thich-y-nghia-do\u1ea1n-ma-sau\"><strong>Gi\u1ea3i th\u00edch \u00fd ngh\u0129a \u0111o\u1ea1n m\u00e3 sau<\/strong><\/h3>\n\n\n\n<pre class=\"wp-block-code\"><code>#import \n@interface MyClass : NSObject\n@end\n@implementation MyClass\n+ (BOOL)resolveInstanceMethod:(SEL)sel {\n    if (sel == @selector(dynamicMethod)) {\n        class_addMethod(self, sel, (IMP)dynamicMethodIMP, \"v@:\");\n        return YES;\n    }\n    return &#91;super resolveInstanceMethod:sel];\n}\nvoid dynamicMethodIMP(id self, SEL _cmd) {\n    NSLog(@\"Dynamic method implementation.\");\n}\n@end<\/code><\/pre>\n\n\n\n<p>Trong \u0111o\u1ea1n m\u00e3 tr\u00ean, ph\u01b0\u01a1ng th\u1ee9c <strong><code>resolveInstanceMethod:<\/code> <\/strong>\u0111\u01b0\u1ee3c ghi \u0111\u00e8 \u0111\u1ec3 th\u00eam m\u1ed9t ph\u01b0\u01a1ng th\u1ee9c m\u1edbi t\u00ean l\u00e0 <strong><code>dynamicMethod<\/code><\/strong> khi ch\u01b0\u01a1ng tr\u00ecnh \u0111ang ch\u1ea1y trong tr\u01b0\u1eddng h\u1ee3p ph\u01b0\u01a1ng th\u1ee9c n\u00e0y ch\u01b0a \u0111\u01b0\u1ee3c tri\u1ec3n khai. Ph\u1ea7n x\u1eed l\u00fd c\u1ee7a <strong><code>dynamicMethod<\/code> <\/strong>\u0111\u01b0\u1ee3c \u0111\u1ecbnh ngh\u0129a trong h\u00e0m <strong><code>dynamicMethodIMP<\/code><\/strong>, nh\u1edd \u0111\u00f3 l\u1edbp <strong><code>MyClass<\/code> <\/strong>c\u00f3 th\u1ec3 \u0111\u00e1p \u1ee9ng v\u00e0 th\u1ef1c thi l\u1eddi g\u1ecdi \u0111\u1ebfn <strong><code>dynamicMethod<\/code><\/strong> m\u1ed9t c\u00e1ch linh ho\u1ea1t v\u00e0 \u0111\u1ed9ng.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"h-cau-h\u1ecfi-th\u1ef1c-hanh-objective-c-nbsp\"><span class=\"ez-toc-section\" id=\"Cau_hoi_thuc_hanh_Objective-C\"><\/span><strong>C\u00e2u h\u1ecfi th\u1ef1c h\u00e0nh Objective-C&nbsp;<\/strong><span class=\"ez-toc-section-end\"><\/span><\/h2>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"h-hay-vi\u1ebft-m\u1ed9t-ch\u01b0\u01a1ng-trinh-tinh-th\u1ec3-tich-h\u1ed9p\"><strong>H\u00e3y vi\u1ebft m\u1ed9t ch\u01b0\u01a1ng tr\u00ecnh t\u00ednh th\u1ec3 t\u00edch h\u1ed9p<\/strong><\/h3>\n\n\n\n<p>Vi\u1ebft m\u1ed9t class Objective-C c\u00f3 t\u00ean Box v\u1edbi ba bi\u1ebfn instance <code>len<\/code>, <code>br<\/code>, <code>h<\/code> v\u00e0 m\u1ed9t property h. Class n\u00e0y c\u00f3 ph\u01b0\u01a1ng th\u1ee9c vol \u0111\u1ec3 t\u00ednh th\u1ec3 t\u00edch c\u1ee7a box b\u1eb1ng c\u00f4ng th\u1ee9c <code>len * br * h<\/code>.&nbsp;<\/p>\n\n\n\n<p>Trong h\u00e0m <code>main<\/code>, t\u1ea1o hai \u0111\u1ed1i t\u01b0\u1ee3ng Box, thi\u1ebft l\u1eadp chi\u1ec1u cao kh\u00e1c nhau cho m\u1ed7i box v\u00e0 in ra th\u1ec3 t\u00edch c\u1ee7a t\u1eebng box.<\/p>\n\n\n\n<p><strong>Code<\/strong><\/p>\n\n\n\n<pre class=\"wp-block-code scroll-9-lines\"><code>#import &lt;Foundation\/Foundation.h&gt;\n@interface Box:NSObject {\n   double len;    \/\/ Chi\u1ec1u d\u00e0i\n   double br;   \/\/ Chi\u1ec1u r\u1ed9ng\n   double h;    \/\/ Chi\u1ec1u cao\n}\n@property(nonatomic, readwrite) double h;  \/\/ Property\n-(double) vol;\n@end\n@implementation Box\n@synthesize h; \n-(id)init {\n   self = &#91;super init];\n   len = 4.0;\n   br = 6.0;\n   return self;\n}\n-(double) vol {\n   return len*br*h;\n}\n@end\nint main() {\n   NSAutoreleasePool * pool = &#91;&#91;NSAutoreleasePool alloc] init];    \n   Box *box1 = &#91;&#91;Box alloc]init];    \/\/ Create box1 object of type Box\n   Box *box2 = &#91;&#91;Box alloc]init];    \/\/ Create box2 object of type Box\n   double vol = 0.0;             \/\/ Bi\u1ebfn l\u01b0u tr\u1eef k\u00edch th\u01b0\u1edbc c\u1ee7a box\n   \/\/ box 1 specification\n   box1.h = 5.0; \n   \/\/ box 2 specification\n   box2.h = 10.0;\n   \/\/ volume of box 1\n   vol = &#91;box1 vol];\n   NSLog(@\"Volume of Box1 : %f\", vol);\n   \/\/ volume of box 2\n   vol = &#91;box2 vol];\n   NSLog(@\"Volume of Box2 : %f\", vol);\n   &#91;pool drain];\n   return 0;\n}<\/code><\/pre>\n\n\n\n<p><strong>Output<\/strong><\/p>\n\n\n\n<figure class=\"wp-block-image\"><img decoding=\"async\" src=\"https:\/\/lh7-rt.googleusercontent.com\/docsz\/AD_4nXd_NEshYSNc_e7b84RYe4trCDGWUu0T7lVJM3pvjVuD4xllm_5iqZlvbp8H1HJqONx-Cp1Jj5x5_JffQk5MXDp8R6Mz3sW3LN2OTbyAk8pwiMZ_GhW-kUL4HTB1Khrj5Mpb2UioBg?key=wqR7ZLscWBFLVRE7Nhd_dLEi\" alt=\"\"\/><\/figure>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"h-hay-t\u1ea1o-giao-th\u1ee9c-tuy-ch\u1ec9nh\"><strong>H\u00e3y t\u1ea1o giao th\u1ee9c t\u00f9y ch\u1ec9nh<\/strong><\/h3>\n\n\n\n<p>H\u00e3y vi\u1ebft m\u1ed9t protocol Objective-C c\u00f3 t\u00ean MyProtocol v\u1edbi m\u1ed9t ph\u01b0\u01a1ng th\u1ee9c <code>doSomething<\/code>.&nbsp;<\/p>\n\n\n\n<p>Sau \u0111\u00f3, t\u1ea1o m\u1ed9t class MyClass k\u1ebf th\u1eeba t\u1eeb NSObject, tu\u00e2n th\u1ee7 (conform) giao th\u1ee9c MyProtocol v\u00e0 tri\u1ec3n khai ph\u01b0\u01a1ng th\u1ee9c <code>doSomething<\/code> \u0111\u1ec3 in ra th\u00f4ng b\u00e1o \u201cDoing something\u2026\u201d.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>\/\/ Creating blue print of the protocol\n@protocol MyProtocol\n\/\/ function in the protocol\n- (void)doSomething;\n@end\n\/\/ Inherited MyClass from NSObject, with \n\/\/ the MyProtocol\n@interface MyClass : NSObject &lt;MyProtocol&gt;\n@end\n\/\/ Implementing the MyClass class. \n@implementation MyClass\n- (void)doSomething {\n    NSLog(@\"Doing something...\");\n}\n@end<\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"h-hay-vi\u1ebft-do\u1ea1n-code-hi\u1ec3n-th\u1ecb-ngay-va-gi\u1edd-theo-d\u1ecbnh-d\u1ea1ng\"><strong>H\u00e3y vi\u1ebft \u0111o\u1ea1n code hi\u1ec3n th\u1ecb ng\u00e0y v\u00e0 gi\u1edd theo \u0111\u1ecbnh d\u1ea1ng<\/strong><\/h3>\n\n\n\n<p>H\u00e3y vi\u1ebft m\u1ed9t ch\u01b0\u01a1ng tr\u00ecnh Objective-C hi\u1ec3n th\u1ecb ng\u00e0y hi\u1ec7n t\u1ea1i theo \u0111\u1ecbnh d\u1ea1ng yyyy-MM-dd. Chuy\u1ec3n \u0111\u1ed5i ng\u00e0y n\u00e0y th\u00e0nh chu\u1ed7i, in ra chu\u1ed7i, sau \u0111\u00f3 chuy\u1ec3n ng\u01b0\u1ee3c chu\u1ed7i th\u00e0nh \u0111\u1ed1i t\u01b0\u1ee3ng NSDate v\u00e0 in ra k\u1ebft qu\u1ea3.<\/p>\n\n\n\n<p><strong>Code<\/strong><\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>\/\/ Objective-C program to display date and time in the specified format\n#import &lt;Foundation\/Foundation.h&gt;\nint main() {\n   NSAutoreleasePool * pool = &#91;&#91;NSAutoreleasePool alloc] init];\n   NSDate *date= &#91;NSDate date];\n   NSDateFormatter *dateFormatter = &#91;&#91;NSDateFormatter alloc]init];\n   \/\/ Setting the format\n   &#91;dateFormatter setDateFormat:@\"yyyy-MM-dd\"];\n   \/\/ Displaying the current format\n   NSString *dateString = &#91;dateFormatter stringFromDate:date];\n   NSLog(@\"Current date is %@\",dateString);\n    \/\/ Displaying the new format\n   NSDate *newDate = &#91;dateFormatter dateFromString:dateString];\n   NSLog(@\"NewDate: %@\",newDate); \n   &#91;pool drain];\n   return 0;\n}<\/code><\/pre>\n\n\n\n<p>Output:<\/p>\n\n\n\n<figure class=\"wp-block-image\"><img decoding=\"async\" src=\"https:\/\/lh7-rt.googleusercontent.com\/docsz\/AD_4nXfRrlNsvVWpmOUPgW9eEmppufqMOgftlRLBzrdK0FykGOwbk8Y2fEICjcUgX0zUxeNvgj5UAJsv33pWVB2BSdO8ajxutABDmOzjkeymVSoW_2bQlwn52CG8XVg76gDpjtjarhF_lQ?key=wqR7ZLscWBFLVRE7Nhd_dLEi\" alt=\"\"\/><\/figure>\n\n\n\n<p><strong>L\u01b0u \u00fd:<\/strong> Trong <code>NSDateFormatter<\/code>, <code>@\"yyyy\"<\/code> bi\u1ec3u th\u1ecb n\u0103m d\u01b0\u01a1ng l\u1ecbch th\u00f4ng th\u01b0\u1eddng, c\u00f2n <code>@\"YYYY\"<\/code> bi\u1ec3u th\u1ecb n\u0103m theo l\u1ecbch tu\u1ea7n ISO (week-based year). Hai gi\u00e1 tr\u1ecb n\u00e0y c\u00f3 th\u1ec3 kh\u00e1c nhau v\u00e0o th\u1eddi \u0111i\u1ec3m g\u1ea7n cu\u1ed1i n\u0103m ho\u1eb7c \u0111\u1ea7u n\u0103m. V\u00ed d\u1ee5, ng\u00e0y 31\/12\/2023 c\u00f3 th\u1ec3 \u0111\u01b0\u1ee3c \u0111\u1ecbnh d\u1ea1ng th\u00e0nh &#8220;2024&#8221; n\u1ebfu d\u00f9ng <code>@\"YYYY\"<\/code> v\u00ec n\u00f3 n\u1eb1m trong tu\u1ea7n \u0111\u1ea7u ti\u00ean c\u1ee7a n\u0103m 2024 theo chu\u1ea9n ISO.&nbsp;<\/p>\n\n\n\n<p>Trong \u0111o\u1ea1n code tr\u00ean, ITviec \u0111\u00e3 s\u1eed d\u1ee5ng <code>@\"yyyy\"<\/code> \u0111\u1ec3 hi\u1ec3n th\u1ecb \u0111\u00fang n\u0103m d\u01b0\u01a1ng l\u1ecbch!<\/p>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"h-hay-vi\u1ebft-m\u1ed9t-do\u1ea1n-ma-b\u1eb1ng-cach-s\u1eed-d\u1ee5ng-category\"><strong>H\u00e3y vi\u1ebft m\u1ed9t \u0111o\u1ea1n m\u00e3 b\u1eb1ng c\u00e1ch s\u1eed d\u1ee5ng category<\/strong><\/h3>\n\n\n\n<p>H\u00e3y vi\u1ebft m\u1ed9t ch\u01b0\u01a1ng tr\u00ecnh Objective-C s\u1eed d\u1ee5ng category \u0111\u1ec3 m\u1edf r\u1ed9ng l\u1edbp NSString b\u1eb1ng c\u00e1ch th\u00eam m\u1ed9t ph\u01b0\u01a1ng th\u1ee9c m\u1edbi c\u00f3 t\u00ean <code>getnumber<\/code> (class method) tr\u1ea3 v\u1ec1 chu\u1ed7i &#8220;Getting the number 111 and function is successfully executed&#8221;. Trong main, g\u1ecdi ph\u01b0\u01a1ng th\u1ee9c n\u00e0y v\u00e0 in ra k\u1ebft qu\u1ea3.<\/p>\n\n\n\n<p><strong>Code:<\/strong><\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>\/\/ Objective-C program for categories\n#import &lt;Foundation\/Foundation.h&gt;\n\/\/ Creating category\n@interface NSString(Mynumber)+(NSString *)getnumber;\n@end\n\/\/ Implementing the method\n@implementation NSString(Mynumber) +(NSString *)getnumber \n{\n   return @\"Getting the number 111 and function is successfully executed\";\n}\n@end\nint main(int argc, const char * argv&#91;]) \n{\n   NSAutoreleasePool * temp = &#91;&#91;NSAutoreleasePool alloc] init];\n   NSString *getnumber = &#91;NSString getnumber];\n   NSLog(@\"output: %@\",getnumber);\n   &#91;temp drain];\n   return 0;\n}<\/code><\/pre>\n\n\n\n<p><strong>Output:<\/strong><\/p>\n\n\n\n<p>Getting the number 111 and function is successfully executed<\/p>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"h-t\u1ed5ng-k\u1ebft\"><span class=\"ez-toc-section\" id=\"Tong_ket\"><\/span><strong>T\u1ed5ng k\u1ebft<\/strong><span class=\"ez-toc-section-end\"><\/span><\/h2>\n\n\n\n<p>Nh\u01b0 v\u1eady, ITviec \u0111\u00e3 t\u1ed5ng h\u1ee3p l\u1ea1i to\u00e0n b\u1ed9 ki\u1ebfn th\u1ee9c v\u1ec1 Objective-C, t\u1eeb l\u00fd thuy\u1ebft n\u1ec1n t\u1ea3ng \u0111\u1ebfn c\u00e1c b\u00e0i th\u1ef1c h\u00e0nh c\u01a1 b\u1ea3n v\u00e0 n\u00e2ng cao. Nh\u1eefng c\u00e2u h\u1ecfi ph\u1ecfng v\u1ea5n Objective-C kh\u00f4ng ch\u1ec9 nh\u1eb1m \u0111\u00e1nh gi\u00e1 k\u1ef9 n\u0103ng l\u1eadp tr\u00ecnh, m\u00e0 c\u00f2n l\u00e0 c\u01a1 h\u1ed9i \u0111\u1ec3 b\u1ea1n h\u1ec7 th\u1ed1ng h\u00f3a ki\u1ebfn th\u1ee9c, hi\u1ec3u s\u00e2u h\u01a1n v\u1ec1 c\u00e1ch ng\u00f4n ng\u1eef n\u00e0y v\u1eadn h\u00e0nh v\u00e0 n\u00e2ng cao s\u1ef1 t\u1ef1 tin khi b\u01b0\u1edbc v\u00e0o m\u00f4i tr\u01b0\u1eddng l\u00e0m vi\u1ec7c. H\u00e3y ki\u00ean tr\u00ec luy\u1ec7n t\u1eadp v\u00e0 kh\u00f4ng ng\u1eebng trau d\u1ed3i \u0111\u1ec3 bi\u1ebfn c\u00e1c c\u00e2u h\u1ecfi n\u00e0y th\u00e0nh l\u1ee3i th\u1ebf trong h\u00e0nh tr\u00ecnh chinh ph\u1ee5c nh\u00e0 tuy\u1ec3n d\u1ee5ng nh\u00e9!<\/p>\n\n\n\n<blockquote class=\"wp-block-quote is-layout-flow wp-block-quote-is-layout-flow\">\n<p><em>\u0110\u1ecdc chi ti\u1ebft: <strong><a href=\"https:\/\/itviec.com\/blog\/objective-c-tutorial\/\" target=\"_blank\" rel=\"noreferrer noopener\">Objective-C tutorial: 14 ng\u00e0y t\u1ef1 h\u1ecdc hi\u1ec7u qu\u1ea3 qua v\u00ed d\u1ee5 th\u1ef1c t\u1ebf&nbsp;<\/a><\/strong><\/em><\/p>\n<\/blockquote>\n","protected":false},"excerpt":{"rendered":"<p>N\u1ebfu b\u1ea1n \u0111ang chu\u1ea9n b\u1ecb cho m\u1ed9t bu\u1ed5i ph\u1ecfng v\u1ea5n v\u1ecb tr\u00ed l\u1eadp tr\u00ecnh vi\u00ean iOS, c\u00f3 th\u1ec3 b\u1ea1n s\u1ebd g\u1eb7p nh\u1eefng c\u00e2u h\u1ecfi xoay quanh Objective-C. B\u1edfi l\u1ebd Objective-C v\u1eabn hi\u1ec7n di\u1ec7n trong nhi\u1ec1u d\u1ef1 \u00e1n c\u0169 v\u00e0 \u0111\u00f2i h\u1ecfi b\u1ea1n ph\u1ea3i hi\u1ec3u r\u00f5 m\u1edbi c\u00f3 th\u1ec3 b\u1ea3o tr\u00ec ho\u1eb7c m\u1edf r\u1ed9ng. Trong b\u00e0i [&hellip;]<\/p>\n","protected":false},"author":213,"featured_media":89045,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"_gspb_post_css":"","footnotes":""},"categories":[109,105],"tags":[],"class_list":["post-88768","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-chuyen-mon-it","category-phong-van-it"],"blocksy_meta":[],"acf":[],"yoast_head":"<!-- This site is optimized with the Yoast SEO Premium plugin v26.8 (Yoast SEO v27.7) - https:\/\/yoast.com\/product\/yoast-seo-premium-wordpress\/ -->\n<title>Top 30+ c\u00e2u h\u1ecfi ph\u1ecfng v\u1ea5n Objective-C t\u1eeb l\u00fd thuy\u1ebft \u0111\u1ebfn th\u1ef1c h\u00e0nh - ITviec Blog<\/title>\n<meta name=\"description\" content=\"H\u01b0\u1edbng d\u1eabn tr\u1ea3 l\u1eddi 30+ c\u00e2u h\u1ecfi ph\u1ecfng v\u1ea5n Objective-C t\u1eeb c\u01a1 b\u1ea3n \u0111\u1ebfn n\u00e2ng cao. Luy\u1ec7n t\u1eadp ngay \u0111\u1ec3 t\u1ef1 tin \u1ee9ng tuy\u1ec3n v\u1ecb tr\u00ed iOS Developer.\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/itviec.com\/blog\/cau-hoi-phong-van-objective-c\/\" \/>\n<meta property=\"og:locale\" content=\"vi_VN\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Top 30+ c\u00e2u h\u1ecfi ph\u1ecfng v\u1ea5n Objective-C t\u1eeb l\u00fd thuy\u1ebft \u0111\u1ebfn th\u1ef1c h\u00e0nh\" \/>\n<meta property=\"og:description\" content=\"N\u1ebfu b\u1ea1n \u0111ang chu\u1ea9n b\u1ecb cho m\u1ed9t bu\u1ed5i ph\u1ecfng v\u1ea5n v\u1ecb tr\u00ed l\u1eadp tr\u00ecnh vi\u00ean iOS, c\u00f3 th\u1ec3 b\u1ea1n s\u1ebd g\u1eb7p nh\u1eefng c\u00e2u h\u1ecfi xoay quanh Objective-C. B\u1edfi l\u1ebd Objective-C v\u1eabn\" \/>\n<meta property=\"og:url\" content=\"https:\/\/itviec.com\/blog\/cau-hoi-phong-van-objective-c\/\" \/>\n<meta property=\"og:site_name\" content=\"ITviec Blog\" \/>\n<meta property=\"article:publisher\" content=\"https:\/\/www.facebook.com\/ITviec\" \/>\n<meta property=\"article:published_time\" content=\"2025-07-06T16:01:54+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2025-07-07T09:33:00+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/itviec.com\/blog\/wp-content\/uploads\/2025\/07\/cau-hoi-phong-van-objective-c-scaled.png\" \/>\n\t<meta property=\"og:image:width\" content=\"800\" \/>\n\t<meta property=\"og:image:height\" content=\"421\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/png\" \/>\n<meta name=\"author\" content=\"Linh Trao\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:creator\" content=\"@ITviec\" \/>\n<meta name=\"twitter:site\" content=\"@ITviec\" \/>\n<meta name=\"twitter:label1\" content=\"\u0110\u01b0\u1ee3c vi\u1ebft b\u1edfi\" \/>\n\t<meta name=\"twitter:data1\" content=\"Linh Trao\" \/>\n\t<meta name=\"twitter:label2\" content=\"\u01af\u1edbc t\u00ednh th\u1eddi gian \u0111\u1ecdc\" \/>\n\t<meta name=\"twitter:data2\" content=\"23 ph\u00fat\" \/>\n<!-- \/ Yoast SEO Premium plugin. -->","yoast_head_json":{"title":"Top 30+ c\u00e2u h\u1ecfi ph\u1ecfng v\u1ea5n Objective-C t\u1eeb l\u00fd thuy\u1ebft \u0111\u1ebfn th\u1ef1c h\u00e0nh - ITviec Blog","description":"H\u01b0\u1edbng d\u1eabn tr\u1ea3 l\u1eddi 30+ c\u00e2u h\u1ecfi ph\u1ecfng v\u1ea5n Objective-C t\u1eeb c\u01a1 b\u1ea3n \u0111\u1ebfn n\u00e2ng cao. Luy\u1ec7n t\u1eadp ngay \u0111\u1ec3 t\u1ef1 tin \u1ee9ng tuy\u1ec3n v\u1ecb tr\u00ed iOS Developer.","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/itviec.com\/blog\/cau-hoi-phong-van-objective-c\/","og_locale":"vi_VN","og_type":"article","og_title":"Top 30+ c\u00e2u h\u1ecfi ph\u1ecfng v\u1ea5n Objective-C t\u1eeb l\u00fd thuy\u1ebft \u0111\u1ebfn th\u1ef1c h\u00e0nh","og_description":"N\u1ebfu b\u1ea1n \u0111ang chu\u1ea9n b\u1ecb cho m\u1ed9t bu\u1ed5i ph\u1ecfng v\u1ea5n v\u1ecb tr\u00ed l\u1eadp tr\u00ecnh vi\u00ean iOS, c\u00f3 th\u1ec3 b\u1ea1n s\u1ebd g\u1eb7p nh\u1eefng c\u00e2u h\u1ecfi xoay quanh Objective-C. B\u1edfi l\u1ebd Objective-C v\u1eabn","og_url":"https:\/\/itviec.com\/blog\/cau-hoi-phong-van-objective-c\/","og_site_name":"ITviec Blog","article_publisher":"https:\/\/www.facebook.com\/ITviec","article_published_time":"2025-07-06T16:01:54+00:00","article_modified_time":"2025-07-07T09:33:00+00:00","og_image":[{"width":800,"height":421,"url":"https:\/\/itviec.com\/blog\/wp-content\/uploads\/2025\/07\/cau-hoi-phong-van-objective-c-scaled.png","type":"image\/png"}],"author":"Linh Trao","twitter_card":"summary_large_image","twitter_creator":"@ITviec","twitter_site":"@ITviec","twitter_misc":{"\u0110\u01b0\u1ee3c vi\u1ebft b\u1edfi":"Linh Trao","\u01af\u1edbc t\u00ednh th\u1eddi gian \u0111\u1ecdc":"23 ph\u00fat"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/itviec.com\/blog\/cau-hoi-phong-van-objective-c\/#article","isPartOf":{"@id":"https:\/\/itviec.com\/blog\/cau-hoi-phong-van-objective-c\/"},"author":{"name":"Linh Trao","@id":"https:\/\/itviec.com\/blog\/#\/schema\/person\/6d1bcbfa05475cbc5a2eaf0727501a16"},"headline":"Top 30+ c\u00e2u h\u1ecfi ph\u1ecfng v\u1ea5n Objective-C t\u1eeb l\u00fd thuy\u1ebft \u0111\u1ebfn th\u1ef1c h\u00e0nh","datePublished":"2025-07-06T16:01:54+00:00","dateModified":"2025-07-07T09:33:00+00:00","mainEntityOfPage":{"@id":"https:\/\/itviec.com\/blog\/cau-hoi-phong-van-objective-c\/"},"wordCount":5984,"publisher":{"@id":"https:\/\/itviec.com\/blog\/#organization"},"image":{"@id":"https:\/\/itviec.com\/blog\/cau-hoi-phong-van-objective-c\/#primaryimage"},"thumbnailUrl":"https:\/\/itviec.com\/blog\/wp-content\/uploads\/2025\/07\/cau-hoi-phong-van-objective-c-scaled.png","articleSection":["Chuy\u00ean m\u00f4n IT","Ph\u1ecfng v\u1ea5n IT"],"inLanguage":"vi"},{"@type":"WebPage","@id":"https:\/\/itviec.com\/blog\/cau-hoi-phong-van-objective-c\/","url":"https:\/\/itviec.com\/blog\/cau-hoi-phong-van-objective-c\/","name":"Top 30+ c\u00e2u h\u1ecfi ph\u1ecfng v\u1ea5n Objective-C t\u1eeb l\u00fd thuy\u1ebft \u0111\u1ebfn th\u1ef1c h\u00e0nh - ITviec Blog","isPartOf":{"@id":"https:\/\/itviec.com\/blog\/#website"},"primaryImageOfPage":{"@id":"https:\/\/itviec.com\/blog\/cau-hoi-phong-van-objective-c\/#primaryimage"},"image":{"@id":"https:\/\/itviec.com\/blog\/cau-hoi-phong-van-objective-c\/#primaryimage"},"thumbnailUrl":"https:\/\/itviec.com\/blog\/wp-content\/uploads\/2025\/07\/cau-hoi-phong-van-objective-c-scaled.png","datePublished":"2025-07-06T16:01:54+00:00","dateModified":"2025-07-07T09:33:00+00:00","description":"H\u01b0\u1edbng d\u1eabn tr\u1ea3 l\u1eddi 30+ c\u00e2u h\u1ecfi ph\u1ecfng v\u1ea5n Objective-C t\u1eeb c\u01a1 b\u1ea3n \u0111\u1ebfn n\u00e2ng cao. Luy\u1ec7n t\u1eadp ngay \u0111\u1ec3 t\u1ef1 tin \u1ee9ng tuy\u1ec3n v\u1ecb tr\u00ed iOS Developer.","breadcrumb":{"@id":"https:\/\/itviec.com\/blog\/cau-hoi-phong-van-objective-c\/#breadcrumb"},"inLanguage":"vi","potentialAction":[{"@type":"ReadAction","target":["https:\/\/itviec.com\/blog\/cau-hoi-phong-van-objective-c\/"]}]},{"@type":"ImageObject","inLanguage":"vi","@id":"https:\/\/itviec.com\/blog\/cau-hoi-phong-van-objective-c\/#primaryimage","url":"https:\/\/itviec.com\/blog\/wp-content\/uploads\/2025\/07\/cau-hoi-phong-van-objective-c-scaled.png","contentUrl":"https:\/\/itviec.com\/blog\/wp-content\/uploads\/2025\/07\/cau-hoi-phong-van-objective-c-scaled.png","width":800,"height":421,"caption":"c\u00e2u h\u1ecfi ph\u1ecfng v\u1ea5n Objective-C - itviec blog"},{"@type":"BreadcrumbList","@id":"https:\/\/itviec.com\/blog\/cau-hoi-phong-van-objective-c\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Chuy\u00ean m\u00f4n IT","item":"https:\/\/itviec.com\/blog\/chuyen-mon-it\/"},{"@type":"ListItem","position":2,"name":"Top 30+ c\u00e2u h\u1ecfi ph\u1ecfng v\u1ea5n Objective-C t\u1eeb l\u00fd thuy\u1ebft \u0111\u1ebfn th\u1ef1c h\u00e0nh"}]},{"@type":"WebSite","@id":"https:\/\/itviec.com\/blog\/#website","url":"https:\/\/itviec.com\/blog\/","name":"ITviec Blog","description":"IT Jobs &amp; People in Vietnam","publisher":{"@id":"https:\/\/itviec.com\/blog\/#organization"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/itviec.com\/blog\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"vi"},{"@type":"Organization","@id":"https:\/\/itviec.com\/blog\/#organization","name":"ITviec","url":"https:\/\/itviec.com\/blog\/","logo":{"@type":"ImageObject","inLanguage":"vi","@id":"https:\/\/itviec.com\/blog\/#\/schema\/logo\/image\/","url":"https:\/\/itviec.com\/blog\/wp-content\/uploads\/2018\/12\/itviec-black-square-facebook.png","contentUrl":"https:\/\/itviec.com\/blog\/wp-content\/uploads\/2018\/12\/itviec-black-square-facebook.png","width":1800,"height":1800,"caption":"ITviec"},"image":{"@id":"https:\/\/itviec.com\/blog\/#\/schema\/logo\/image\/"},"sameAs":["https:\/\/www.facebook.com\/ITviec","https:\/\/x.com\/ITviec","https:\/\/www.linkedin.com\/company\/itviec","https:\/\/www.youtube.com\/channel\/UCYthAQ3bcGr57M_ag5gHDvQ"]},{"@type":"Person","@id":"https:\/\/itviec.com\/blog\/#\/schema\/person\/6d1bcbfa05475cbc5a2eaf0727501a16","name":"Linh Trao","image":{"@type":"ImageObject","inLanguage":"vi","@id":"https:\/\/itviec.com\/blog\/wp-content\/uploads\/2024\/03\/trao-thi-tung-linh-author-e1709892478113-100x100.jpg","url":"https:\/\/itviec.com\/blog\/wp-content\/uploads\/2024\/03\/trao-thi-tung-linh-author-e1709892478113-100x100.jpg","contentUrl":"https:\/\/itviec.com\/blog\/wp-content\/uploads\/2024\/03\/trao-thi-tung-linh-author-e1709892478113-100x100.jpg","caption":"Linh Trao"},"url":"https:\/\/itviec.com\/blog\/author\/linh-trao\/"}]}},"_links":{"self":[{"href":"https:\/\/itviec.com\/blog\/wp-json\/wp\/v2\/posts\/88768","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/itviec.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/itviec.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/itviec.com\/blog\/wp-json\/wp\/v2\/users\/213"}],"replies":[{"embeddable":true,"href":"https:\/\/itviec.com\/blog\/wp-json\/wp\/v2\/comments?post=88768"}],"version-history":[{"count":5,"href":"https:\/\/itviec.com\/blog\/wp-json\/wp\/v2\/posts\/88768\/revisions"}],"predecessor-version":[{"id":89084,"href":"https:\/\/itviec.com\/blog\/wp-json\/wp\/v2\/posts\/88768\/revisions\/89084"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/itviec.com\/blog\/wp-json\/wp\/v2\/media\/89045"}],"wp:attachment":[{"href":"https:\/\/itviec.com\/blog\/wp-json\/wp\/v2\/media?parent=88768"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/itviec.com\/blog\/wp-json\/wp\/v2\/categories?post=88768"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/itviec.com\/blog\/wp-json\/wp\/v2\/tags?post=88768"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}