<commit_before>//
//  Copyright © 2015 It<NAME>. All rights reserved.

import UIKit

final class NonSerializableViewController: RevertViewController {
  @IBOutlet private weak var progressView: UIProgressView!
  @IBOutlet private weak var subView: UIView!
  @IBOutlet private weak var slider: UISlider!

  override func viewDidLoad() {
    super.viewDidLoad()

    self.slider.addTarget(self, action: "warnBeforeCrash:", forControlEvents: .TouchUpInside)
  }

  func warnBeforeCrash(sender: UISlider?) {
    let alertTitle = NSLocalizedString("Modifying the UISlider again will cause the app to crash", comment: "Unserializable slider title")
    let alertMessage = NSLocalizedString("This is intentional, and demonstrates what happens when a property is not serializable.", comment: "Unserializable slider message")

    if #available(iOS 8.0, *) {
      let alertViewController = UIAlertController(
        title: alertTitle,
        message: alertMessage,
        preferredStyle: .Alert
      )

      let continueAction = UIAlertAction(
        title: NSLocalizedString("Ok", comment: "Alert Ok button title"),
        style: .Default) { [weak self] _ in
          self?.dynamicType.makeSliderUnserializable(self)

          // Only show the alert once
          self?.slider.removeTarget(self, action: "warnBeforeCrash:", forControlEvents: .TouchUpInside)
      }

      alertViewController.addAction(continueAction)

      self.presentViewController(alertViewController, animated: true, completion: nil)
    } else {
      let alertView = UIAlertView(
        title: alertTitle,
        message: alertMessage,
        delegate: nil,
        cancelButtonTitle: NSLocalizedString("OK", comment: "Unserializable slider OK button")
      )

      alertView.show()
    }

  }

  private static func makeSliderUnserializable(viewController: NonSerializableViewController?) {
    // inf
    viewController?.slider.maximumValue = 1 / 0

    // nan
    viewController?.progressView.contentScaleFactor = 0 / 0

    // - inf
    viewController?.subView.contentScaleFactor = -1 / 0
  }
}

extension NonSerializableViewController: UIAlertViewDelegate {

  func alertView(alertView: UIAlertView, willDismissWithButtonIndex buttonIndex: Int) {
    self.dynamicType.makeSliderUnserializable(self)

    // Only show the alert once
    self.slider.removeTarget(self, action: "warnBeforeCrash:", forControlEvents: .TouchUpInside)
  }

}<commit_msg>Implement a couple of changes based on feedback from Hugo<commit_after>//
//  Copyright © 2015 Itty Bitty Apps. All rights reserved.

import UIKit

final class NonSerializableViewController: RevertViewController {
  @IBOutlet private weak var progressView: UIProgressView!
  @IBOutlet private weak var subView: UIView!
  @IBOutlet private weak var slider: UISlider!

  override func viewDidLoad() {
    super.viewDidLoad()

    self.slider.addTarget(self, action: "warnBeforeCrash:", forControlEvents: .TouchUpInside)
  }

  func warnBeforeCrash(sender: UISlider?) {
    let alertTitle = NSLocalizedString("Modifying the UISlider again will cause the app to crash", comment: "Unserializable slider title")
    let alertMessage = NSLocalizedString("This is intentional, and demonstrates what happens when a property is not serializable.", comment: "Unserializable slider message")

    if #available(iOS 8.0, *) {
      let alertViewController = UIAlertController(
        title: alertTitle,
        message: alertMessage,
        preferredStyle: .Alert
      )

      let continueAction = UIAlertAction(
        title: NSLocalizedString("Ok", comment: "Alert Ok button title"),
        style: .Default) { [weak self] _ in
          self?.makeSliderUnserializable()

          // Only show the alert once
          self?.slider.removeTarget(self, action: "warnBeforeCrash:", forControlEvents: .TouchUpInside)
      }

      alertViewController.addAction(continueAction)

      self.presentViewController(alertViewController, animated: true, completion: nil)
    } else {
      let alertView = UIAlertView(
        title: alertTitle,
        message: alertMessage,
        delegate: nil,
        cancelButtonTitle: NSLocalizedString("OK", comment: "Unserializable slider OK button")
      )

      alertView.show()
    }

  }

  private func makeSliderUnserializable() {
    // inf
    self.slider.maximumValue = 1 / 0

    // nan
    self.progressView.contentScaleFactor = 0 / 0

    // - inf
    self.subView.contentScaleFactor = -1 / 0
  }
}

extension NonSerializableViewController: UIAlertViewDelegate {

  func alertView(alertView: UIAlertView, willDismissWithButtonIndex buttonIndex: Int) {
    self.makeSliderUnserializable()

    // Only show the alert once
    self.slider.removeTarget(self, action: "warnBeforeCrash:", forControlEvents: .TouchUpInside)
  }

}
{'fraction_non_alphanumeric': 0.08765354986466792, 'fraction_numerical': 0.004996876951905059, 'mean_word_length': 3.5235404896421847, 'pattern_counts': {'":': 0, '<': 4, '<?xml version=': 0, '>': 4, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '972792', 'n_tokens_mistral': 1372, 'n_tokens_neox': 1293, 'n_words': 365}