Skip to content

Commit

Permalink
[Modify #1] inject context as python code
Browse files Browse the repository at this point in the history
  • Loading branch information
Enchan1207 committed Aug 17, 2021
1 parent 95ee403 commit 92307d0
Showing 1 changed file with 2 additions and 9 deletions.
11 changes: 2 additions & 9 deletions ExternalProcessEx/ViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -14,22 +14,15 @@ class ViewController: NSViewController {

let process = Process()
process.executableURL = .init(fileURLWithPath: "/usr/bin/python3")
process.arguments = ["-r", "print('Hello, World')"]

// パイプ生成
let inputPipe = Pipe(), outputPipe = Pipe()
process.standardInput = inputPipe.fileHandleForReading
process.standardOutput = outputPipe.fileHandleForWriting

// まずは実行
// 実行
do {
try process.run()
} catch {
print(error)
}

// 突っ込んでみる
inputPipe.fileHandleForWriting.write("print(\"Hello, World!\")".data(using: .utf8)!)

}

override var representedObject: Any? {
Expand Down

0 comments on commit 92307d0

Please sign in to comment.