加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 百科 > 正文

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

发布时间:2020-12-14 19:21:45 所属栏目:百科 来源:网络整理
导读:我对 Xcode甚至编程都不熟悉. 从Xcode开始,在我的代码中,如何显示控制台并清除屏幕? 我知道我可以用Xcode首选项来做,但我想以编程方式进行. 解决方法 这对我有用 – 如果您希望Xcode保持在应用程序之上,请省略最后一个激活部分: bool ClearXCodeDebuggerCo
我对 Xcode甚至编程都不熟悉.

从Xcode开始,在我的代码中,如何显示控制台并清除屏幕?

我知道我可以用Xcode首选项来做,但我想以编程方式进行.

解决方法

这对我有用 – 如果您希望Xcode保持在应用程序之上,请省略最后一个激活部分:

bool ClearXCodeDebuggerConsole()
{
    NSString *const scriptText = @"
tell application "System Events"n
set currentapp to the name of the current applicationn
end telln
tell application "Xcode" to activaten
tell application "System Events"n
keystroke "r" using {command down,control down,option down}n
end telln
tell application currentapp to activaten
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;
}

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读