Skip to content

Commit

Permalink
Swift 4.1 updates
Browse files Browse the repository at this point in the history
  • Loading branch information
wtmoose committed Apr 2, 2018
1 parent 0c27983 commit 4e3c826
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 1 deletion.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ All notable changes to this project will be documented in this file.
## 4.1.2

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

### Bug Fixes
Expand Down
2 changes: 1 addition & 1 deletion SwiftMessages/Animator.swift
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ public class AnimationContext {

public protocol Animator: class {

weak var delegate: AnimationDelegate? { get set }
var delegate: AnimationDelegate? { get set }

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

Expand Down
4 changes: 4 additions & 0 deletions SwiftMessages/MessageView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,11 @@ open class MessageView: BaseView, Identifiable, AccessibleMessage {
open var accessibilityPrefix: String?

open var accessibilityMessage: String? {
#if swift(>=4.1)
let components = [accessibilityPrefix, titleLabel?.text, bodyLabel?.text].compactMap { $0 }
#else
let components = [accessibilityPrefix, titleLabel?.text, bodyLabel?.text].flatMap { $0 }
#endif
guard components.count > 0 else { return nil }
return components.joined(separator: ", ")
}
Expand Down
4 changes: 4 additions & 0 deletions SwiftMessages/SwiftMessages.swift
Original file line number Diff line number Diff line change
Expand Up @@ -776,7 +776,11 @@ extension SwiftMessages {
}
}
let arrayOfViews = resolvedBundle.loadNibNamed(name, owner: filesOwner, options: nil) ?? []
#if swift(>=4.1)
guard let view = arrayOfViews.compactMap( { $0 as? T} ).first else { throw SwiftMessagesError.cannotLoadViewFromNib(nibName: name) }
#else
guard let view = arrayOfViews.flatMap( { $0 as? T} ).first else { throw SwiftMessagesError.cannotLoadViewFromNib(nibName: name) }
#endif
return view
}
}
Expand Down

0 comments on commit 4e3c826

Please sign in to comment.