简体   繁体   English

表达式结果未使用警告,但不想使用它

[英]Expression result unused warning but don't want to use it

I am getting an expression result unused, the cause of this is pretty obvious but I would like to avoid this warning in the cleanest way possible: 我得到一个未使用的表达式结果,其原因很明显,但我想以最简洁的方式避免此警告:

- (void)applicationDidFinishLaunching:(NSNotification *)aNotification
{
    [_window setReleasedWhenClosed:TRUE];
    [_window close];
    [[HotkeyHandler alloc] init:self];
}

HotkeyHandler is another class that basically listens for hotkeys. HotkeyHandler是另一个基本上侦听热键的类。 I just need it to be initialized and that's all it needs to do. 我只需要初始化它,这就是它要做的全部。 I don't use any of its methods since these will be triggered by system notifications. 我不使用其任何方法,因为它们将由系统通知触发。 Any ideas on circumventing this warning? 关于规避此警告有什么想法吗?

The problem is that the instance you created will be dealloc'ed once you leave that method, so it won't be able to listen the notifications. 问题在于,一旦离开该方法,您创建的实例将被取消分配,因此它将无法监听通知。 Why don't you make that class a singleton? 你为什么不让那个班级单身呢?

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM