我对Xcode和编程都比较新手。
在我的代码中,如何从Xcode显示控制台并清除屏幕?
我知道可以通过Xcode首选项完成,但我想以编程的方式实现。
我对Xcode和编程都比较新手。
在我的代码中,如何从Xcode显示控制台并清除屏幕?
我知道可以通过Xcode首选项完成,但我想以编程的方式实现。
bool ClearXCodeDebuggerConsole()
{
NSString *const scriptText = @"\
tell application \"System Events\"\n\
set currentapp to the name of the current application\n\
end tell\n\
tell application \"Xcode\" to activate\n\
tell application \"System Events\"\n\
keystroke \"r\" using {command down, control down, option down}\n\
end tell\n\
tell application currentapp to activate\n\
return true";
NSAppleScript *script = [[[NSAppleScript alloc] initWithSource:scriptText] autorelease];
[scriptText release];
NSDictionary *dictError = nil;
NSAppleEventDescriptor *result = [script executeAndReturnError:&dictError];
if (!result) return false;
if ([result booleanValue] != YES) return false;
return true;
}
您可以通过按下 Shift + Command + R 来显示控制台窗口。您可以通过按下 Control + Option + Command + R 来清除控制台窗口。这两个选项都可以从“运行”菜单中使用。