Skip to content

Commit

Permalink
Fix broken Swift 3.2 build. (#3556)
Browse files Browse the repository at this point in the history
  • Loading branch information
andersio committed Dec 24, 2017
1 parent 9eee050 commit 30a08cc
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 2 deletions.
3 changes: 2 additions & 1 deletion .travis.yml
Expand Up @@ -43,7 +43,8 @@ jobs:
- gem install cocoapods
- pod repo update
- pod lib lint ReactiveCocoa.podspec
- pod lib lint ReactiveMapKit.podspec --swift-version=3.2
- pod lib lint ReactiveCocoa.podspec --swift-version=3.2
- pod lib lint ReactiveMapKit.podspec
env:
- JOB=PODSPEC
- script: carthage build --cache-builds --no-skip-current
2 changes: 2 additions & 0 deletions CHANGELOG.md
@@ -1,6 +1,8 @@
# master
*Please put new entries at the top.

1. Fix an issue preventing ReactiveCocoa from being built with the Swift 3.2 language mode. (#3556)

# 7.1.0-rc.1
1. Requires ReactiveSwift 3.1.0 Release Candidate 1. (#3555)

Expand Down
13 changes: 12 additions & 1 deletion ReactiveCocoa/AppKit/NSTextView.swift
Expand Up @@ -4,7 +4,11 @@ import enum Result.NoError

extension Reactive where Base: NSTextView {
private var notifications: Signal<Notification, NoError> {
#if swift(>=4.0)
let name = NSTextView.didChangeNotification
#else
let name = Notification.Name.NSControlTextDidChange
#endif

return NotificationCenter.default
.reactive
Expand All @@ -15,7 +19,14 @@ extension Reactive where Base: NSTextView {
/// A signal of values in `String` from the text field upon any changes.
public var continuousStringValues: Signal<String, NoError> {
return notifications
.map { ($0.object as! NSTextView).string }
.map { notification in
let textView = notification.object as! NSTextView
#if swift(>=4.0)
return textView.string
#else
return textView.string ?? ""
#endif
}
}

/// A signal of values in `NSAttributedString` from the text field upon any
Expand Down

0 comments on commit 30a08cc

Please sign in to comment.