From 225b203c9e2efe50124318c799822cb6f765db07 Mon Sep 17 00:00:00 2001 From: Feng Qiang <498460828@qq.com> Date: Tue, 30 Jan 2018 09:43:03 +0800 Subject: [PATCH] some time self is zombie object (#45) * update CocoaPods version number --- Sources/SwiftShell/Stream/Stream.swift | 7 +++++-- SwiftShell.podspec | 2 +- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/Sources/SwiftShell/Stream/Stream.swift b/Sources/SwiftShell/Stream/Stream.swift index 52dd42b..1a315b3 100644 --- a/Sources/SwiftShell/Stream/Stream.swift +++ b/Sources/SwiftShell/Stream/Stream.swift @@ -119,8 +119,11 @@ extension ReadableStream { /// - Note: if the stream is read from outside of the handler, or more than once inside /// the handler, it may be called once when stream is closed and empty. public func onOutput(_ handler: @escaping (ReadableStream) -> Void) { - filehandle.readabilityHandler = { [unowned self] _ in - handler(self) + filehandle.readabilityHandler = { [weak self] _ in + guard let wSelf = self else { + return + } + handler(wSelf) } } diff --git a/SwiftShell.podspec b/SwiftShell.podspec index 7258637..7f5ad31 100644 --- a/SwiftShell.podspec +++ b/SwiftShell.podspec @@ -1,6 +1,6 @@ Pod::Spec.new do |s| s.name = 'SwiftShell' - s.version = '4.0.0' + s.version = '4.0.1' s.summary = 'A Swift framework for shell scripting.' s.description = 'SwiftShell is a library for creating command-line applications and running shell commands in Swift.' s.homepage = 'https://github.com/kareman/SwiftShell'