Use `DEPRECATED_ATTRIBUTE` to clean up your code


Actually, DEPRECATED_ATTRIBUTE is a macro, it is defined as:

 * only certain compilers support __attribute__((deprecated))
#if defined(__GNUC__) && ((__GNUC__ >= 4) || ((__GNUC__ == 3) && (__GNUC_MINOR__ >= 1)))
    #define DEPRECATED_ATTRIBUTE __attribute__((deprecated))

It’s very clear that this macro is actually using __attribute__((deprecated)) which is “One of the best (but little known) features of GNU C, which allows a developer to attach characteristics to function declarations to allow the compiler to perform more error checking”. To use it with GNU C, you need to set -Wall option to compiler. /via Steve Friedl

When and where to use DEPRECATED_ATTRIBUTE

OK, this macro is so useful, when and where should I use it?

First of all, this can be used on Objective-C method and properties.

Second, let’s see some common scenes.

  1. To deprecate a method in a widely used library. If you are writing an open-source library and you don’t want to crash your user’s app, this macro is definitely your best friend.
  2. To replace a method with new a new one. Xcode’s refactoring is not so good on adding/deleting a parameter to a method. This macro can help you a lot.

Add this macro, compile it , find the warnings, fix them, ship your app! That’s it, as simple as you can image.

You can always find me on Twitter as @TonnyXu or Facebook

How to integrate MVC pattern with GCD/KVO/CoreData in iOS

My publication

Last year, I published this article on Software Design Issue November. The whole article was written in Japanese. Since I’m not a native Japanese, I’d like to thank my fellow coworkers Nagano/7gano and Kato/guruguruman to help me review the article again and again. Without your help, I could not make this happen.

View the content

The Japanese title of this article is iOS でのMVCパターンの再検討およびCore Data、GCD、KVOの実践運用

The article was coordinated with Gihyo‘s format and it’s hard to layout it again, so, I’d like to share the finished page in PDF with everyone.

View the article in PDF

Brief content in English

  • CoreData is powerful, and if you don’t have legacy database to conform to, use it
  • KVO is super powerful, but come with side effect. It can help you with your multiple UI update, and can also mess your code flow
  • GCD is awesome! forget about delegate, use GCD whenever possible with multithread programming
  • All these technologies comes great with MVC pattern

Finally, as always, follow me on Twitter or Facebook

Jan 19, 2011, public speech at PasonaTech Japan

User, User, User

This is a public speech I gave to PasonaTech‘s seminar on smart phone development. Basically, this is not a technical speech, in this session, I proposed that every engineer should focus on what the user really want, not just what your superior what. In order to do so, you need to whatever you can on the full development process.

As always, remember to follow me on Twitter, or on Facebook

Fibonacci Number

Fibonacci Number is a very common topic in everyday life, because it has a tight relationship with golden ratio Φ(Phi).

In CS, calculate the nth fibonacci number is also an interesting problem. Here is a Lightening Talk I gave to my company’s engineer on March 22, 2012. Take a look at it if you are looking for a job now, or you just don’t know how to calculate a fibonacci number.

Meanwhile, don’t forget to follow me on twitter, or on Facebook