iOS’ 카테고리의 보관물

Using Blocks in iOS 4: The Basics

목요일, 2월 2nd, 2012

Using Blocks in iOS 4: The Basics

http://pragmaticstudio.com/blog/2010/7/28/ios4-blocks-1

Day 1: Minutes to Midnight

월요일, 12월 12th, 2011

 

  • In the document window “File’s Owner”
  • Click: Tools->Idenity Inspector
  • In the inspector click the + under “Class Outlets”
  • Change myOutlet1 to “countdownLabel”
  • Change id to UILabel
  • Click enter to make sure they commit

Day 1: Minutes to Midnight

연관이 없는 object들 간의 메세지 전달방법 : notification, KVO

화요일, 11월 22nd, 2011

1. notification  (하나의 어플리케이션 안에는 하나의 노티피케이션센터만이 존재한다)

   [[NSNotificationCenter defaultCenter] addObserver:self 
                                                                selector:@selector(실행될함수명:)
                                                                name:@”전달할메시지”
                                                                object:nil ];
 
  이렇게 선언해놓고 m파일에 실행될 함수를 만들자!!
  
  -(void)실행될함수명:(NSNotification *)notification
  {
        실행될 로직…..
  }
 
  이제 어떤 변화가 일어 날경우 노티피케이션 센터에 메세지를 전달시켜줘서 노티피케이션이 실행되게끔 해야 한다.
  [[NSNotificationCenter defaultCenter] postNotificationName:@”전달할메시지” object:self];
  변경될 부분에 이렇게 메시지를 전달하면 노티피케이션에서 메시지를 받아서 실행될 함수를 실행한다.
   끗.. 자주 쓰인다고함..
 
2.  KVO (Key Value Observing) 키값 감시

  델리게이트 app가 실행될때

[클레스 addObserver:self forKeyPath:@”감시할값” 

 options:NSKeyValueObservingOptionNew | NSKeyValueObservingOptionOld 

 context:nil];

  이렇게 선언해준다.

  그담 observer가 감지될때 실행할 함수를 등록한다. 함수명 자동완성이 안될땐 addObserver 도움말을 참조하자..

  – (void)observeValueForKeyPath:(NSString *)keyPath ofObject:(id)object 

                     change:(NSDictionary *)change context:(void *)context

     {

if ([keyPath isEqualToString:@”감시할값”]) {

            [self 실행될함수명];

 }

      }

 

 

Mac Keyboard Symbol

금요일, 11월 4th, 2011

Mac Keyboard Symbol

   늘 헷갈릴때마다 보고 외우자~~