2010-10-05 11 views
5

Ich bin etwas neu zu Xcode und sogar Programmierung.Xcode-Konsole, Bildschirm klar programmierbar

Von Xcode, in meinem Code, wie zeige ich die Konsole und den Bildschirm löschen?

Ich weiß, ich könnte es mit den Xcode-Einstellungen tun, aber ich möchte es programmgesteuert tun.

Antwort

1

Sie können das Konsolenfenster anzeigen, indem Sie Umschalt + Befehl + R drücken. Sie können das Konsolenfenster löschen, indem Sie Strg + Wahl + Befehl + R drücken. Beide Optionen sind im Menü Ausführen verfügbar.

+0

Danke für hier aushelfen, aber dieses hat mich nicht programmatisch helfen. – eGanges

3

Dies funktioniert für mich - lassen Sie den letzten Teil aktivieren, wenn Sie Xcode wollen auf Ihre App bleiben:

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; 
} 
+0

Accurate für AppKit (OS X), aber leider nicht so für iOS UIKit. Insbesondere die von der AppKit-Dokumentation @import Foundation abgeleitete iOS-Bibliothek #import unterstützt NSAppleScript und NSAppleEventDescriptor nicht. https://developer.apple.com/library/mac/documentation/Cocoa/Reference/Foundation/Classes/NSAppleScript_Class/ – eGanges