2009-10-13 11 views
1

我遇到以下blog post解釋的主題。但是,我對給定的樣品有麻煩。測試目標 - 動作接線

它驗證目標 - 動作像這樣綁定:

STAssertEquals([doSomethingButton action], @selector(doSomething:), 
    @"The button should send -doSomething: to its target."); 

STAssertEquals([doSomethingButton target], _windowController, 
    @"The button should send its action to the window controller."); 

這工作只要doSomethingButton是UIBarButton。 UISwitch或UIButton沒有目標或操作屬性。我嘗試了以下斷言他們的目標 - 動作接線:

GHAssertNotNil([[controller logSwitch] actionsForTarget:controller forControlEvent:UIControlEventValueChanged], nil); 

但是,它未能即使我已確認操作的模擬器正確調用。 UIControl的目標動作接線的正確方法是什麼?

UPDATE:

UIControl - (NSSet *)allTargets 

似乎即使調試應用程序,並在稱爲行動執行它沒有返回,!

回答

2

它真的好像是UIKit框架中的一個bug。我向蘋果提交了一個錯誤報告。