Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save linearhw/f6d321c655ab0e57ff4c23c4606e40e8 to your computer and use it in GitHub Desktop.
Save linearhw/f6d321c655ab0e57ff4c23c4606e40e8 to your computer and use it in GitHub Desktop.
Effective Objective-C 38
typedef int(^EOCSomeBlock)(Bool flag, int value);

EOCSomeBlock block = ^(Bool flag, int value){
    // 구현 내용
};

이렇게 하는 게 좋은 이유는?

  • 가독성.
  • API 구조가 바뀌어서 parameter 가 변경되었을 때 리팩토링하기 편하다.

똑같은 구조의 타입을 다른 이름으로 여러 개 만들게 되는데?

  • 문제 없다. 타입은 적은 것보다 많은 게 좋다.
  • 똑같은 parameter 와 return type 을 가지는 블록이어도 이름을 보고 어떤 일을 하는지 쉽게 파악 가능하다.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment