Skip to content

Commit

Permalink
Return no preferredAction for action sheets (#256)
Browse files Browse the repository at this point in the history
The documentation for UIAlertController.preferredAction specifies this
is only relevant for alerts, so this mimics that behavior more
accurately.
  • Loading branch information
sberrevoets authored Dec 22, 2017
1 parent 460d013 commit dcd86bb
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions Source/AlertController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,10 @@ public class AlertController: UIViewController {
@objc
public var preferredAction: AlertAction? {
get {
if self.preferredStyle == .actionSheet {
return nil
}

let index = self.actions.index { $0.style == .preferred }
return index != nil ? self.actions[index!] : nil
}
Expand Down

0 comments on commit dcd86bb

Please sign in to comment.