<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Green Chiu on Medium]]></title>
        <description><![CDATA[Stories by Green Chiu on Medium]]></description>
        <link>https://medium.com/@greenchiu1986?source=rss-e64b0cf8830f------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*LCj2f1JJSRUr1S2DiDl1cQ.jpeg</url>
            <title>Stories by Green Chiu on Medium</title>
            <link>https://medium.com/@greenchiu1986?source=rss-e64b0cf8830f------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Fri, 04 Dec 2026 19:21:09 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@greenchiu1986/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[How to help the new member? Perfect the on-boarding process.]]></title>
            <link>https://medium.com/@greenchiu1986/how-to-help-the-new-member-perfect-the-on-boarding-process-86f9778ce654?source=rss-e64b0cf8830f------2</link>
            <guid isPermaLink="false">https://medium.com/p/86f9778ce654</guid>
            <category><![CDATA[onboarding]]></category>
            <dc:creator><![CDATA[Green Chiu]]></dc:creator>
            <pubDate>Mon, 04 Feb 2019 14:43:55 GMT</pubDate>
            <atom:updated>2019-02-05T16:42:48.924Z</atom:updated>
            <content:encoded><![CDATA[<p>Last April, I joined honestbee. At there, I experienced a wonderful journey, made new friends, learned new things , and had a great memory.</p><p>honestbee builds a great on-boarding process for new employees. There are several sessions to introduce their service and how it works. Besides, each function team (iOS, Android, FE … etc.) has its own on-boarding sessions.</p><p>That’s really great. Those sessions really help me understand the business model and what honestbee is doing !</p><p>Because of that experience, I think a good on-boarding process is important and necessary. It not only can help us and new members to save time, but also can provide the main and significant information for them.</p><p>As a result, I want to build on-boarding process for Lang.</p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fgiphy.com%2Fembed%2FCjmvTCZf2U3p09Cn0h%2Ftwitter%2Fiframe&amp;display_name=Giphy&amp;url=https%3A%2F%2Fmedia.giphy.com%2Fmedia%2FCjmvTCZf2U3p09Cn0h%2Fgiphy.gif&amp;image=https%3A%2F%2Fi.giphy.com%2Fmedia%2FCjmvTCZf2U3p09Cn0h%2Fgiphy.gif&amp;key=d04bfffea46d4aeda930ec88cc64b87c&amp;type=text%2Fhtml&amp;schema=giphy" width="435" height="409" frameborder="0" scrolling="no"><a href="https://medium.com/media/299d92410c85baea4abbb6ad6d7f7285/href">https://medium.com/media/299d92410c85baea4abbb6ad6d7f7285/href</a></iframe><h3>Think what we want the new member to be</h3><p>Before I start to build the on-boarding process, I am thinking about what’s the goal we hire him/her.</p><ul><li>To solve the insufficient resources.</li><li>To solve the technical-debt.</li><li>Be enthusiastic and free at work.</li></ul><p>And other limited situations we have.</p><ul><li>Just 1~2 weeks for on-boarding.</li><li>Most of us are busy during the development cycle.</li></ul><p>Then, I start to plan the process. The process has four parts as followings:</p><ul><li>General</li><li>Programming</li><li>Others</li><li>Sessions</li></ul><p>Besides, we need the buddy and mentor to guide new members. They can ask for help or questions from the mentor/buddy. Through this way, I hope our new members can adapt to their team quickly and smoothly.</p><h3>The on-boarding process</h3><h4>General</h4><ul><li>Join the group of IMs.</li><li>Apply the access for git, document service … etc.</li><li>Apply the access for tools of development.</li><li><strong>Have lunch with other members.</strong></li><li><strong>Buddy introduces everyone to you.</strong></li></ul><h4>Programming</h4><ul><li>Get the source code and run it.</li><li>Read the documents.</li><li>Learn the skill we are using.</li></ul><h4>Others</h4><ul><li>Use our service, install the app and start it.</li><li>Assignment.</li><li>Join a code review.</li></ul><h4>Sessions</h4><ul><li>Introduce our Service and App.</li><li>Programming guidelines, development and release cycle.</li><li>2 – 3 technical sessions.</li></ul><p>Finally, we have <strong>Development Handbook </strong>for everyone.</p><ul><li>For new members, we hope you start the new position and work quickly and easily.</li><li>For others, go to the section and read the details you need.</li></ul><p>This is just the first step, and there will be many problems and obstacles when we perfect it, just keep reviewing and adjusting the content to fit the goals and current situation for team.</p><p>On the other hand, the on-boarding process is a good way to build culture and growing mindsets. What’s your expectations for the team? What’s the mindset that you hope members to have? Take them into your consideration and revise the process to reach your expectations.</p><p>Perhaps it is hard to achieve, but if we just think without any action, it will never come true, right?</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=86f9778ce654" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[巨集的應用 (1)]]></title>
            <link>https://medium.com/ios-nerd/%E5%B7%A8%E9%9B%86%E7%9A%84%E6%87%89%E7%94%A8-1-acd3e52022d2?source=rss-e64b0cf8830f------2</link>
            <guid isPermaLink="false">https://medium.com/p/acd3e52022d2</guid>
            <category><![CDATA[ios]]></category>
            <category><![CDATA[programming]]></category>
            <category><![CDATA[objective-c]]></category>
            <dc:creator><![CDATA[Green Chiu]]></dc:creator>
            <pubDate>Thu, 17 May 2018 05:57:27 GMT</pubDate>
            <atom:updated>2018-05-17T05:57:27.363Z</atom:updated>
            <content:encoded><![CDATA[<p><em>如果想找 Swift 如何使用巨集，這篇文章沒有相關的訊息，請持續追蹤後續的文章，謝謝。</em></p><p>Macro (巨集) 在 Xcode, Objective-C and Swfit 中皆有應用，其中在 Objective-C 的開發以及 Xcode 專案的建置上被大量的使用。Swift 使用的方式上跟 Objective-C 有極大的差異，後續的文章將會繼續討論。</p><p>今天再來談談幾個會用到 macro 的情境，我依照我個人的經驗列出下面的項目：</p><ul><li>Define variables.</li><li>Adapter</li><li>NOT Simple but usually use method or function</li><li>Use Preprocessor Macros to Enable specific information or tool.</li></ul><p>上面的項目我會拆分成幾個部分來分享，希望內容能在兩到三篇內結束。</p><p>首先我們先來了解在 Objective-C 中，該如何定義巨集跟幾個會使用到的寫法。我列出了四個我們經常使用的方法：</p><pre>#ifdef<br>#ifndef<br>#define<br>#undef</pre><p>ifdef/ifndef 是 C Preprocessor 的 condition compilation，用來檢查巨集是否存在，再接著執行對應的陳述式。可以參考下面的 code block：</p><pre>#ifdef DEBUG<br>// do something<br>#endif</pre><p>這邊要特別注意的事情是，如果條件是沒有成立，<em>#ifdef </em>裡面的動作將會被 Xcode 直接忽略，無法知道你的實作是否正確；可以先把 macro 加進去或是把先暫時移除 <em>#ifdef </em>來確保實做正確。</p><pre>#define MACRO</pre><pre>#ifdef MACRO<br>// Your statement is working<br>#endif</pre><pre>#undef MACRO</pre><pre>#ifdef MACRO<br>// Your statement can not work<br>#endif</pre><h3>Define variable</h3><p>使用 macro 來定義變數，可能是最直接且大多人最喜歡的使用方式了。<br>我們來來看看該如何來定義 macro 變數：</p><pre>#define {Macro_Name} {Value} </pre><pre>#define Author @&quot;Green&quot; <br>#define Age @30<br>#define Own_a_house NO</pre><p>上面我定義了一個三個不同的 macro 變數，分別是 <strong><em>Author</em></strong><em>、</em><strong><em>Age</em></strong><em> 以及 </em><strong><em>Own_a_house</em></strong><em>，</em>對應的 value 是 <strong><em>Green</em></strong>、 <strong><em>30</em></strong> 以及 <strong><em>NO</em></strong>；使用起來也非常簡單：</p><pre>if (!Own_a_house) {<br>    // Do something<br>}</pre><pre>NSString *name = Author;<br>NSInteger age = [Age integerValue];</pre><p>透過上面的例子，我們可以發現定義 macro 變數的時候，<strong>不用特別指定類型</strong>就可以隨意的將值指定成 Objective-C 所支援的類型，使用的方式也相同。</p><p>雖然是很方便的方式，但是我並不推薦這樣使用的使用方式。在<a href="https://medium.com/ios-nerd/%E8%AE%8A%E6%95%B8-in-objective-c-e83e0d8cf7e8">變數 in Objective-C</a> 中我有討論到這樣使用會遭遇到的問題與推薦作法，沒看過可以看一下，這邊就不詳述了。</p><h3>Adapter</h3><p>在開發的過程中，大家會經常使用 NSLog 來 Trace/Log 需要的資訊來做除錯/驗證，為了不把這些資訊洩漏出去，通常完成的時候再去移除相關的 NSLog。如果在 QA 驗證時候有問題就又必須在把 NSLog 加回去。這一來一往所花費的時間累積起來也是很可觀的。</p><p>而 macro 可以讓我們輕鬆地解決這個問題：</p><pre>#ifdef DEBUG<br>#define NSLog NSLog<br>#else<br>#define NSLog<br>#endif</pre><p>上述程式碼，我宣告了一個 macro <strong>NSLog</strong> ，在有定義 DEBUG 的版本中，他會直接呼叫 <em>NSLog</em> <em>func</em>，不然除了定義 <em>DEBUG</em> 外的版本去使用 <strong>NSLog</strong> 都會沒有作用，連之前已經加上沒移除的 <em>NSLog func </em>都會直接被<em> </em>macro<strong> NSLog</strong><em> </em>覆蓋。</p><p>這樣的做法能除了能減少花費在處理 Log 的時間，同時讓 QA 在使用 Debug 版本也能看到這些資訊，降低開發者與 QA 的溝通成本。</p><p>除了這個例子之外，我們也很常使用 NSLocalizedString 來支援在地化。NSLocalizedString 需要帶入兩個參數，分別是 “Key” 及 “Comment”，其中的 Comment 可以帶入 nil。用起來會的方式如下：</p><pre>NSLocalizedString(@&quot;key for string&quot;, nil);</pre><p>如果這個專案對於在地化的需求並沒有使用 comment 的需求，一直反覆的輸入這麼長的名稱且每次都要帶入 nil 也很累。這時候也可以透過 Macro 來幫忙改善這個問題</p><pre>#define NSLSTR(key) NSLocalizedString(key, nil)</pre><p>透過新的 macro <strong>NSLSTR</strong>，就能減少需要輸入很長的名稱以及帶入 nil 花費的時間。</p><p>也許你有注意到，在第二個範例裡面我並沒有直接用同樣的變數名稱來定義<strong> </strong>NSLocalizedString；主要的原因是因為 NSLocalizedString 本身也是 macro，雖然可以重複的定義相同名稱的 macro，但是這樣很容易造成混淆，因此在對待 macro 的處理方式，會建議你使用新的命名來做一些區分。</p><p>以上是關於 macro 變數跟使用 macro 來轉換/橋接不同實作的經驗分享，如果你有疑問或是很棒的想法，歡迎提出來一起討論。</p><p>That’s all, enjoy it.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=acd3e52022d2" width="1" height="1" alt=""><hr><p><a href="https://medium.com/ios-nerd/%E5%B7%A8%E9%9B%86%E7%9A%84%E6%87%89%E7%94%A8-1-acd3e52022d2">巨集的應用 (1)</a> was originally published in <a href="https://medium.com/ios-nerd">iOS Nerd 🤓</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Intro to NSCache and more.]]></title>
            <link>https://medium.com/@greenchiu1986/intro-to-nscache-and-more-2f4d58b3c58c?source=rss-e64b0cf8830f------2</link>
            <guid isPermaLink="false">https://medium.com/p/2f4d58b3c58c</guid>
            <category><![CDATA[ios]]></category>
            <category><![CDATA[programming]]></category>
            <dc:creator><![CDATA[Green Chiu]]></dc:creator>
            <pubDate>Mon, 07 May 2018 04:33:06 GMT</pubDate>
            <atom:updated>2018-05-08T06:21:40.865Z</atom:updated>
            <content:encoded><![CDATA[<p>Do you profile your new feature/application before submission? Do you notice the rate of OOM (Out of Memory) from your dashboard ?</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/510/1*_rlj85fWbU1kgmWGY1_n2w.jpeg" /><figcaption>App crashed when key moment</figcaption></figure><p>We should always take care and investigate what the root causes, and we may find two most common issues as following:</p><ul><li>Memory leaks</li><li>Use too much memory</li></ul><p>Memory leaks must be solved and how to deal the second issue? Reduce data store in memory ? Use low-quality image? Write data into disk and read it when you need? …etc. The above are all the solutions.</p><p>But, how do we start with them ? Does it impact the user experience? Does the modification make it worse or do we meet other issues?</p><p>We shall step by step. Let us start to reduce data store in memory( or fine tune the memory usage).</p><p>So, we should start to monitor the data size and schedule timer to calculate memory usage? That sounds terrible!?</p><p>Fortunately, Apple provides a nice solution for this, NSCache.</p><blockquote>NSCache — A mutable collection you use to temporarily store transient key-value pairs that are subject to eviction when resources are low.</blockquote><p>NSCache is designed with key-value pairs and thread-safe, what you need to do is to set the <strong>countLimit</strong> and <strong>totalCostLimit, </strong>then put your data into the NSCache.<strong> </strong>That sounds good and easy, doesn’t it? You can also set a specific cost for a key. Maybe you hope specific data not to be evicted or you want do something when evicting data. There are two ways for you.</p><ul><li>Implement <strong>NSCacheDelegae </strong>method cache:willEvictObject:</li><li>Implement <strong>NSDiscardableContent </strong>for your data, prevent it from being evicted.</li></ul><p>It’s easy to apply to your codebase and doesn’t take lots of effort on you, just find what data is important and what is not.</p><p>I think you will love it, it’s not only help to manage memory usage, but also reduce your effort on data management.</p><p>Even though NSCache is nice and easy, but I still want to introduce you another component, <a href="https://github.com/greenchiu/gxcache">GXCache</a>.</p><p>GXCache is a lightweight cache component. It’s auto-release memory when your app receives memory warning, and you still can retrieve it when you access it again. ( Yes, I implemented lazy-loading for it. )</p><p>And Swift version is on the way, I will complete it asap.</p><p>That’s all, enjoy.</p><p><strong>Thanks </strong><a href="https://medium.com/u/455eede53a04"><strong>Liyao Chen</strong></a><strong> and </strong><a href="https://medium.com/u/140cd83feb90"><strong>Pofat</strong></a><strong>s’ sharing, </strong><a href="https://medium.com/u/161403fefde8"><strong>Czars Chou</strong></a><strong>’s help.</strong></p><h4>Reference</h4><ul><li><a href="https://developer.apple.com/documentation/foundation/nscache">NSCache | Apple Developer Documentation</a></li><li><a href="https://stackoverflow.com/questions/11520815/nscache-is-not-evicting-data">NSCache is not evicting data</a></li><li><a href="https://stackoverflow.com/questions/13163480/nscache-and-background/13579963#13579963">NSCache and background</a></li></ul><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=2f4d58b3c58c" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[變數 in Objective-C]]></title>
            <link>https://medium.com/ios-nerd/%E8%AE%8A%E6%95%B8-in-objective-c-e83e0d8cf7e8?source=rss-e64b0cf8830f------2</link>
            <guid isPermaLink="false">https://medium.com/p/e83e0d8cf7e8</guid>
            <category><![CDATA[programming]]></category>
            <category><![CDATA[ios]]></category>
            <dc:creator><![CDATA[Green Chiu]]></dc:creator>
            <pubDate>Sun, 15 Apr 2018 17:12:35 GMT</pubDate>
            <atom:updated>2018-04-16T08:50:56.454Z</atom:updated>
            <content:encoded><![CDATA[<p>在 Objective C 中宣告變數的方式在不同的情況下會有使用不同的方式，這次想要跟大家分享關於宣告<strong>全域</strong>變數的部分。</p><p>先讓我們看看該如何宣告變數? 下面列出兩個方式來定義變數</p><pre>NSString *aString = @&quot;sample&quot;;<br>#define ASTRING @&quot;MACRO_SAMPLE&quot;</pre><p>上面的兩個方式，分別是使用 NSString 以及 macro 分別宣告兩個不同的字串。兩種方式各有優缺，不過我們應該盡量使用第一種做法來宣告變數。至於 marco，通常都會使用在別的地方。</p><p>Why?</p><p>直接使用 Class 宣告的好處是：</p><ol><li>變數的型別很清楚，即使命名不夠明確，你依然可以透過 Xcode 的 Auto-complete 快速的了解該變數的型別。</li><li>如果有重複宣告(即使在不同的 Class 中)，Complie 會失敗，可以快速的修正錯誤。</li><li>可以使用 <strong>external</strong> 在 .h 中先進行宣告，而後在 .m 定義；而且還可以定義在不同 Class 中。</li></ol><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*-sOm77lJcEbpBw6mwjuIOw.png" /><figcaption>使用 Auto-complete 你可以快速了解到這個變數的型別</figcaption></figure><pre>// Example for 3.<br>// in MySimple.h</pre><pre>external NSString *const MSSimpleNotification;</pre><pre>@interface MySimple : NSObject <br>@end</pre><pre>// in MySimpleTask.m</pre><pre>NSString *const MSSimpleNotification = @&quot;SimpleNotification&quot;;<br>@implementation MySimpleTask<br>@end</pre><p>上面的 simple code 中，用這樣的方式來宣告變數，可以避免繁雜的 import，就能讓 MySimpleTask 直接使用 <strong>MSSimpleNotification</strong>。</p><p>為什麼不使用 marco 來定義變數？</p><p>除了上述說的 Auto-complete 並無法幫助你了解這個變數之外， marco 是可以重複定義的；你可以想像你有三個同事都叫吳恥仁，當有人跟你說你要找吳恥仁去達成某件事，如果他沒有特別交代是哪一個，你會知道該找誰嗎？更何況，你還能使用 #undef 來取消之前宣告的 macro 。</p><p>相比起來，使用 Class 直接宣告的變數讓你寫出來的程式更容易被其他人閱讀跟維護。</p><p>那什麼時候使用 macro ？在<strong>重複使用</strong>、<strong>簡單</strong>的 method/判斷式上，你可以將它定義成 marco ，以便快速地使用。</p><pre>#define MAKE_FAST_ERROR(error_code, error_desc) ( [NSError errorWithDomain: .... ] )<br>#define INVALIDETE_TIME( time ) if (time) { \<br>[time invalidate]; \<br>time = nil; } <br>#define DEGREE_TO_PI ...</pre><p>上面的第一個例子，我定義了一個只需要提供 error code 以及 description 就能快速產生 NSError 的 macro，在實作錯誤回饋的時候，就能省下不少時間。</p><p>除了這樣的使用方式之外，我們也常常在專案中使用 #ifdef 來判斷是否定義了某些 marco ，來確定/保護某些功能只出現在特定的版本中之。</p><p>當然，依照不同的情境，還是會有使用 macro 來定義參數，尤其是在使用 Preprocessor Marcos 的時候。如果之後有機會分享建置流程再跟大家進一步分享這邊的內容。</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=e83e0d8cf7e8" width="1" height="1" alt=""><hr><p><a href="https://medium.com/ios-nerd/%E8%AE%8A%E6%95%B8-in-objective-c-e83e0d8cf7e8">變數 in Objective-C</a> was originally published in <a href="https://medium.com/ios-nerd">iOS Nerd 🤓</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Think about Protocol in Objective-C]]></title>
            <link>https://medium.com/@greenchiu1986/think-about-protocol-in-objective-c-4ccca13d2ae9?source=rss-e64b0cf8830f------2</link>
            <guid isPermaLink="false">https://medium.com/p/4ccca13d2ae9</guid>
            <category><![CDATA[objective-c]]></category>
            <category><![CDATA[ios]]></category>
            <dc:creator><![CDATA[Green Chiu]]></dc:creator>
            <pubDate>Tue, 17 Oct 2017 13:28:16 GMT</pubDate>
            <atom:updated>2017-10-17T13:28:16.612Z</atom:updated>
            <content:encoded><![CDATA[<p>What do you think when you see <strong>Protocol </strong>in Objective-C? Inherit? Delegation Pattern? or others?</p><p>Let me guess the answer, <strong>Delegation Pattern. </strong>Most of answers are Delegation Pattern cause Apple heavily used Protocol with Delegation in <em>UIKit</em>, such as <em>UITableView, UICollectionView and UIImagePicker …etc. </em>Maybe someone implementing <em>NSCopying, NSCoding </em>for class could be archived or copied.</p><p>In the past, I reviewed lot of code using protocol only for delegation, and that included me. What else can we use Protocol? And I try it to refactor.</p><p>How does a protocol look?</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/9653169ae97cd8e8e29b479539c61dfb/href">https://medium.com/media/9653169ae97cd8e8e29b479539c61dfb/href</a></iframe><p>Protocol looks just an agreement, it declares <em>methods, properties</em> and what is <em>required </em>and what is <em>optional</em>.</p><p>Let me share an experience that using protocol to refactor for you.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/26b44bcdc1acea08887594a5c69a4f44/href">https://medium.com/media/26b44bcdc1acea08887594a5c69a4f44/href</a></iframe><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/246d8734d8b250dc20fa51dcd1ecb43e/href">https://medium.com/media/246d8734d8b250dc20fa51dcd1ecb43e/href</a></iframe><p>According to the above gists, we could find cells use <strong>LocalSongInfo </strong>and <strong>LocalPlaylistInfo </strong>to get image and load it, but that looks complex, the cell might import several classes just for getting image; I hope they will be simple and do not import so many classes just for getting image. So, I declare a protocol <strong>LocalItemImageProvider </strong>for them.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/c0e7160f95e5e3840afaf8e13b2145b2/href">https://medium.com/media/c0e7160f95e5e3840afaf8e13b2145b2/href</a></iframe><p>Then let LocalSongInfo and LocalPlaylistInfo implement it; Let’s review how songCell looks like after LocalSongInfo implemented the protocol.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/c0b4ca78dcfd8647e2e23a37d6cba5b2/href">https://medium.com/media/c0b4ca78dcfd8647e2e23a37d6cba5b2/href</a></iframe><p>That looks better than before, there are not redundant classes, we succeed to reduce the coupling; but … it’s still a little bit complex, is there other way to make it more maintainable? Yes, we can add a <strong><em>Category </em></strong>for <strong><em>UImage </em></strong>to handle the Protocol.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/e4fba704aea7bc3be42b9c1b1ff355a5/href">https://medium.com/media/e4fba704aea7bc3be42b9c1b1ff355a5/href</a></iframe><p>Finally, the SongCell.m looks as following:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/f75d22ac442adced8ae888d741022e2f/href">https://medium.com/media/f75d22ac442adced8ae888d741022e2f/href</a></iframe><p>It looks clearer and easier to maintain.</p><p>And maybe protocol is a solution for complex inheritance hierarchy; when a level of class inheritance hierarchy is more than four, it can be considered to refactor and try to separate some function to new class or protocol. I will share you when I use it with that case.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=4ccca13d2ae9" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[iOS Memory Management]]></title>
            <link>https://medium.com/@greenchiu1986/ios-memory-management-784bd52f75a3?source=rss-e64b0cf8830f------2</link>
            <guid isPermaLink="false">https://medium.com/p/784bd52f75a3</guid>
            <category><![CDATA[ios]]></category>
            <dc:creator><![CDATA[Green Chiu]]></dc:creator>
            <pubDate>Wed, 01 Mar 2017 09:15:35 GMT</pubDate>
            <atom:updated>2017-03-01T09:15:35.903Z</atom:updated>
            <content:encoded><![CDATA[<p>Last year, I had interview for iOS Software Engineer and the interviewer had question about Memory Management and asked me to explain how it work.</p><p>Unfortunately, My answer was not enough to convince interviewer that I understand that mechanism. So I wrote this.</p><p>There are two way to manage memory:</p><ul><li>Manual Retain-Release (MRR)</li><li>Automatic Reference Counting (ARC)</li></ul><p>Before start talking MRR or ARC, we should know how the system know an object is existed. And there is a system named reference-counting system.</p><p>Every object has property retainCount. If the number is greater than zero, means object is existed. When the number goes down to zero, means it is not existed longer.</p><p>In MRR environment, we should add release or autorelease to decrease retainCount and increase by calling retain or copy. And Makes sure the actions are balance, otherwise it causes memory leak or crash. And implements release-action at dealloc method to relinquish properties.</p><p>In ARC, we didn’t add retain , release and retain anymore. The compiler helps us to take care that, but we still do relinquishment when we no longer the use it.</p><p>And What is a object be released? Or How to release a object? <br>In my opinion, just relinquish the ownership, set the object to nil.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=784bd52f75a3" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[MaskView for UIView]]></title>
            <link>https://medium.com/@greenchiu1986/maskview-for-uiview-59fe423af5ee?source=rss-e64b0cf8830f------2</link>
            <guid isPermaLink="false">https://medium.com/p/59fe423af5ee</guid>
            <category><![CDATA[ios]]></category>
            <dc:creator><![CDATA[Green Chiu]]></dc:creator>
            <pubDate>Thu, 02 Feb 2017 04:22:24 GMT</pubDate>
            <atom:updated>2017-02-02T04:22:24.126Z</atom:updated>
            <content:encoded><![CDATA[<p>How do u implement mask for view?<br>I did that with CALayer, and recently I find out other way to do it.</p><p>UIView has a property ‘maskView’ from iOS 8, it’s simple and easy to use.<br>There are three things u must to know.</p><p>1. Don’t add maskView into any view.<br>2. The frame of maskView is related to its owner.<br>3. Give a color and the alpha channel is not zero for maskView, cause the alpha channel is used to mask a view’s content.</p><pre>UIView *owner = [[UIView alloc] initWithFrame:CGRectMake(10.f, 20.f, 200.f, 200.f)];<br>owner.backgroundColor = [UIColor redColor];<br>[self.view addSubview:owner];</pre><pre>UIView *mask = [[UIView alloc] initWithFrame:CGRectMake(0.f, 0.f, 20.f, 20.f)];<br>mask.backgroundColor = [UIColor whiteColor];<br>owner.maskView = mask;</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/640/1*MokTe7PbDmpvuPeIdmm0Nw.png" /></figure><p>And that’s all.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=59fe423af5ee" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Hello World.]]></title>
            <link>https://medium.com/@greenchiu1986/hello-world-11e1ae6401c8?source=rss-e64b0cf8830f------2</link>
            <guid isPermaLink="false">https://medium.com/p/11e1ae6401c8</guid>
            <dc:creator><![CDATA[Green Chiu]]></dc:creator>
            <pubDate>Sun, 22 Jan 2017 09:01:07 GMT</pubDate>
            <atom:updated>2017-01-22T09:01:07.884Z</atom:updated>
            <content:encoded><![CDATA[<p>Hi, I’m Green.<br>After I failed to install Octorpress at my new mbp, I decided to write something with Medium, I’m no longer to update blog on <a href="https://greenchiu.github.io/">greenchiou.github.io</a>.</p><p>And I will write in English, that’s my resolution this year, I hope it’s help to improve my expression and English.</p><p>That’s all, hope to have new ideas could share with u.</p><p>Green.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=11e1ae6401c8" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>