2011-05-13 5 views

답변

0

iOS4를 사용중인 경우 알림을 블록으로 전달할 수있는 것처럼 보입니다. NSNotificationCenter 스포츠이 방법 :

- (id)addObserverForName:(NSString *)name object:(id)obj queue:(NSOperationQueue *)queue usingBlock:(void (^)(NSNotification *))block NS_AVAILABLE(10_6, 4_0); 

그런 다음 당신이 뭔가를 할 수 :

MyClass.m :

static void (^receiveNote)(NSNotification *) = ^(NSNotification * note) 
{ 
    UITextField * field = [ note object ] ; 
    // forward notification to C++ here 
} ; 

...

@implementation MyClass 

...

-(void)setUpNotifications 
{ 
    [ [ NSNotificationCenter defaultCenter ] addObserverForName:UITextFieldTextDidChangeNotification 
                 object:self.textField 
                  queue:[ NSOperationQueue mainQueue ] 
                usingBlock:receiveNote ] ; 
} 
+0

Mac OS X은 iOS가 아니지만이 기능을 사용해 보겠습니다. 감사합니다. –

+0

오 - OS X 10.6에서도 사용 가능합니다. – nielsbot

+0

NSSearchField가 C++ 클래스로 래핑되었으므로 게시 된 알림을 특정 C++ 클래스 인스턴스로 다시 링크 할 수 있습니까? –

관련 문제