- Joined
- Feb 6, 2011
- Messages
- 13
- Reaction score
- 0
- Points
- 1
Hi everyone! I am new to swift - and new in general to programming on mac osx.
I want to get an array of open windows - loop through them and print out to a console each of the names of the open windows.
So far I have made a new Cocoa application, in Swift, and in my AppDelegate.swift added the following code:
Needless to say - it doesn't like my println line - can't find the write syntax to just write text to a console and also - it seems I am not declaring the CFArray correctly - to store the response array of dictionaries from my CGWindowListCopyWindowInfo call.
Am I on the right track? What should I change the syntax to? Any pointers would be ace!
I want to get an array of open windows - loop through them and print out to a console each of the names of the open windows.
So far I have made a new Cocoa application, in Swift, and in my AppDelegate.swift added the following code:
Code:
import Cocoa
@NSApplicationMain
class AppDelegate: NSObject, NSApplicationDelegate {
func applicationDidFinishLaunching(_ aNotification: Notification) {
// Insert code here to initialize your application
println("hello world");
CFArray windows = CGWindowListCopyWindowInfo(CGWindowListOption.optionAll, CGWindowID.kCGNullWindowID);
}
func applicationWillTerminate(_ aNotification: Notification) {
// Insert code here to tear down your application
}
}
Needless to say - it doesn't like my println line - can't find the write syntax to just write text to a console and also - it seems I am not declaring the CFArray correctly - to store the response array of dictionaries from my CGWindowListCopyWindowInfo call.
Am I on the right track? What should I change the syntax to? Any pointers would be ace!