gpt4 book ai didi

Xcode 控制台,以编程方式清屏

转载 作者:行者123 更新时间:2023-12-02 07:38:05 26 4
gpt4 key购买 nike

我对 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;
}

关于Xcode 控制台,以编程方式清屏,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3865878/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com