Skip to content

Commit 4e3c826

Browse files
committed
Swift 4.1 updates
1 parent 0c27983 commit 4e3c826

File tree

4 files changed

+10
-1
lines changed

4 files changed

+10
-1
lines changed

CHANGELOG.md

+1
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ All notable changes to this project will be documented in this file.
44
## 4.1.2
55

66
### Features
7+
* Updates for Swift 4.1
78
* #164 Added an optional `windowViewController` property to `SwiftMessages.Config` for supplying a custom subclass of `WindowViewController`.
89

910
### Bug Fixes

SwiftMessages/Animator.swift

+1-1
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ public class AnimationContext {
6060

6161
public protocol Animator: class {
6262

63-
weak var delegate: AnimationDelegate? { get set }
63+
var delegate: AnimationDelegate? { get set }
6464

6565
func show(context: AnimationContext, completion: @escaping AnimationCompletion)
6666

SwiftMessages/MessageView.swift

+4
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,11 @@ open class MessageView: BaseView, Identifiable, AccessibleMessage {
9595
open var accessibilityPrefix: String?
9696

9797
open var accessibilityMessage: String? {
98+
#if swift(>=4.1)
99+
let components = [accessibilityPrefix, titleLabel?.text, bodyLabel?.text].compactMap { $0 }
100+
#else
98101
let components = [accessibilityPrefix, titleLabel?.text, bodyLabel?.text].flatMap { $0 }
102+
#endif
99103
guard components.count > 0 else { return nil }
100104
return components.joined(separator: ", ")
101105
}

SwiftMessages/SwiftMessages.swift

+4
Original file line numberDiff line numberDiff line change
@@ -776,7 +776,11 @@ extension SwiftMessages {
776776
}
777777
}
778778
let arrayOfViews = resolvedBundle.loadNibNamed(name, owner: filesOwner, options: nil) ?? []
779+
#if swift(>=4.1)
780+
guard let view = arrayOfViews.compactMap( { $0 as? T} ).first else { throw SwiftMessagesError.cannotLoadViewFromNib(nibName: name) }
781+
#else
779782
guard let view = arrayOfViews.flatMap( { $0 as? T} ).first else { throw SwiftMessagesError.cannotLoadViewFromNib(nibName: name) }
783+
#endif
780784
return view
781785
}
782786
}

0 commit comments

Comments
 (0)