views:

92

answers:

1

Hi,

i came across the following blog post that explained the topic. However I do have troubles with the given samples.

It verifies target-action binding like so:

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.");

This works as long as doSomethingButton is a UIBarButton. UISwitch or UIButton don't have a target or action property. I tried the following to assert on their target-action wiring:

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

However, it fails even though I have confirmed the action is properly called in the simulator. What is the right way to assert on target-action wiring for a UIControl?

UPDATE:

UIControl - (NSSet *)allTargets

seems to return nothing, even if debugging the application and executing it in the called action!!!

+2  A: 

It really seems to be a bug in the UIKit framework. I have filed a bug report to Apple.

Johannes Rudolph