performance - Objective-C: Function-Like Macro Vs. Method -
in objective-c, when recommend using function-like macros on class or instance methods?
they're different things. function or method exists once in code; macro inserts entire definition code every time use it.
some people take advantage of fact short macro can expand chunk of code, rather cheap substitute c++ style templates. matt gallagher's singleton macro 1 example. , templates, overuse of large macros can lead surprisingly large code , big debugging headaches.
aside constants , tiny expressions, if can use function or method in place of macro, should.
Comments
Post a Comment