具体而言,它在文本字段焦点方面表现不一致.
我有一个LSUIElement弹出一个状态菜单.在该菜单中,有一个包含文本字段的视图.文本字段需要是可选择的 - 默认情况下不一定是选中,而是以任何方式选择.
单击状态项时,将触发
[NSApp activateIgnoringOtherApps:YES];
Run Code Online (Sandbox Code Playgroud)
它的工作时间大约是一半时间.*状态菜单的另一半似乎是"在后台",并且不会让我把焦点放在文本字段上,即使点击它也是如此.(我知道状态项单击触发器正在触发b/c上有一个NSLog.)
这是Apple处理这些状态项的方式中的错误,还是我错误处理activateIgnoringOtherApps?
*事实上,它似乎只是在另一个应用程序被激活后第一次失败.之后它工作正常.
完整代码段:
-(void)statusItemClicked:(id)sender {
//show the popup menu associated with the status item.
[statusItem popUpStatusItemMenu:statusMenu];
//activate *after* showing the popup menu to obtain focus for the text field.
[NSApp activateIgnoringOtherApps:YES];
}
Run Code Online (Sandbox Code Playgroud) 看起来很容易将一个布尔值添加到NSMutableArray中.
假设toDoArray初始化为NSMutableArray.下列:
BOOL checkBoxState = NO;
[toDoArray addObject:checkBoxState];
Run Code Online (Sandbox Code Playgroud)
生成错误"尝试插入nil".
将负布尔值添加到可变数组的正确方法是什么?