![]() ![]() As any AppleScript user will know, a real droplet is the answer to so many tasks – a little app, often with no front end at all, which takes whatever you throw at it, from single docs to bulging folders, and chugs through, doing its job. But similar examples appear in writing complete Swift apps, suggesting that they are viewed as being somehow normal and good. In Swift practice, they have become windows or views onto which you drag and drop files for processing.Įrica Sadun’s playground example is understandable: views like that in a playground are intended for just this sort of task. I think that this is actually easier than AppleScript’s do shell script, and it works fine in a playground.ĭroplet apps are another matter. Where the final line ensures that you cannot run it again before it has completed. Let task = Process.launchedProcess(launchPath: path, arguments: ) Once I had resolved this confusion, I came up with a playground example of an innocuous command call: Swift playgrounds suggested that I tried the Process class, which I couldn’t find in the Swift docs because – in its alphabetical class list – Process appears between NSString and NSTextCheckingResult, as if it was still NSTask.Īnd the contents of the class docs are also ambiguous, repeatedly referring to it as NSTask. I was looking for what transpired to be an obsolete function in the NSTask class, within Foundation, which no longer exists. This was definitely made much more difficult by dreadful errors in Xcode’s Swift documentation. Most example code lags the current Xcode 8.1, Swift 3, and macOS 10.12 combination that are required for best playground support, so once again I had to convert from old versions. As before, finding the answer depended on negotiating my way through the ‘documentation’. Of course Swift can execute other tasks or processes for me the key question was how easily, and whether this was supported in a playground. AppleScript’s do shell script is one of its primary reasons for survival. ![]() Indeed, some very useful applications are little more than an accessible front-end to various shell commands. These proved more difficult in parts.Ī lot of tools created using scripting systems such as AppleScript and Automator work primarily by putting a friendly wrapper around a command which you could use in Terminal. This next session tried to ride that same wave of success, looking at making command shell calls, producing droplet apps, and folder actions. Last time I looked at scaling, ease of producing little scripts, and had my first success in scripting file actions using Xcode’s Swift playgrounds.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |