Fixed a problem with the boolean:

    NSNumber *result = @(sender.state == NSOnState);

actually doesn’t work! Doing

    CFNumberGetType((CFNumberRef)result)

reveals that the term in brackets is interpreted as an kCFNumberSInt32Type, rather than a kCFNumberCharType. With a cast to BOOL it works though.

    NSNumber *result = @((BOOL)(sender.state == NSOnState));