title: Variables Not Set Intermittently
body: <p>The app I'm working walks the user through an interview and spits out a PDF with product recommendations based on their answers. I'm currently having a problem with some phones not setting the variables properly at unpredictable times.</p>
  
  <p>The data is stored in a class instance named "newTracker", and (for the scope of this question) the answers are stored as bool. The example code is from a screen with only a single question, a UISwitch, and a "Next" button.</p>
  
  <pre><code>class viewWireVolume: UIViewController {
  
      // MARK: Properties
  
      // MARK: Outlets
  
      @IBOutlet weak var outWireVolume: UISwitch!
  
      // MARK: Init
  
      func UIInit(_ animated: Bool) {
  
          outWireVolume.setOn(newTracker.customerMoreThanOneWire, animated: animated)
  
      }
  
      override func viewWillAppear(_ animated: Bool) {
  
          super.viewWillAppear(animated)
          UIInit(false)
  
      }
  
      // MARK: Actions
  
      @IBAction func actionWireVolume(_ sender: Any) { newTracker.customerMoreThanOneWire = outWireVolume.isOn }
  
      // MARK: Interface
  
  }
  </code></pre>
  
  <p>Most of the time this code works fine, but once in a while, it won't save the variable newTracker.customerMoreThanOneWire. When it happens, it happens all over the app, and the code is structured the same. I had a problem in the past where it <em>was</em> saving the variable properly, just not setting the initial switch state properly, but in this instance, it's not saving things at all.</p>
  
  <p>Would it help if the variables were set on Value Change instead of Touch Up Inside? I'm perplexed as to why this only happens at random.
  I have had one of the phones in my hands when this went down, and there were no other apps running in the background, the OS was updated, and there didn't seem to be any shenanigans like jailbreaking or anything else happening.</p>
  
  <p>I have not been able to replicate this with an emulator or a phone hooked into my development machine.</p>
  
  <p>Any insights?</p>
  
  <p>EDIT: Here is the answer tracker code.</p>
  
  <pre><code>class AnswerTracker: NSObject {
  
  // MARK: Variables
  
  /// Name of the business as type: String
  var businessName = ""
  
  // Customer Entity Type
  var entityType: Int = 0                                     // 0 = None Selected, 1 - 7 = Corp, LLC, Part, LP, SP, NP, Muni
  
  // How will customers pay?
  var customerPayCredit: Bool = false
  var customerPayChecks: Bool = false
  var customerPayCash: Bool = false
  var customerPayDirectDebit: Bool = false
  
  // How will checks be deposited?
  var customerDepositChecksOffice: Bool = false
  var customerDepositChecksBranch: Bool = false
  var customerDepositChecksATM: Bool = false
  var customerDepositChecksNight: Bool = false
  
  // How will cash be deposited?
  var customerDepositCashBranch: Bool = false
  var customerDepositCashATM: Bool = false
  var customerDepositCashNight: Bool = false
  
  // How will you pay vendors?
  var customerPayVendorsOnline: Bool = false
  var customerPayVendorsCheck: Bool = false
  var customerPayVendorsCredit: Bool = false
  var customerPayVendorsDebit: Bool = false
  var customerPayVendorsWire: Bool = false
  var customerPayVendorsTransfer: Bool = false
  
  // Do you want to stap unauthed checks?
  var customerPreventUnauthedChecks: Bool = false
  
  // How will you do wire transfers?
  var customerWireInitiateOnline: Bool = false
  var customerWireRequestOnline: Bool = false
  var customerWireRequestBranch: Bool = false
  
  // Will you regularly do more than one wire per month?
  var customerMoreThanOneWire: Bool = false
  
  // How will you pay your employees?
  var customerEmployeePayCheck: Bool = false
  var customerEmployeePayDirect: Bool = false
  var customerEmployeePayCompany: Bool = false
  
  // How will you manage your accounts?
  var customerManageAccountsOnlineSingle: Bool = false
  var customerManageAccountsOnlineMultiple: Bool = false
  var customerManageAccountsBranch: Bool = false
  
  // How will you get your account statements?
  var customerAccountStatementsOnline: Bool = false
  var customerAccountStatementsPaper: Bool = false
  
  // What will you do with excess funds?
  var customerExcessFundsSweep: Bool = false
  var customerExcessFundsSavings: Bool = false
  var customerExcessFundsCD: Bool = false
  var customerExcessFundsFDIC: Bool = false
  
  // How will you handle overdrafts?
  var customerOverdraftsLineOfCredit: Bool = false
  
  // Additional lending?
  var customerLoansAndLinesFunding: Bool = false
  var customerLoansAndLinesRefi: Bool = false
  
  // Would you like to maintain a $3,500 dailyy balance to earn interest?
  var customerReceiveInterest: Bool = false
  
  // Would you like to switch your existing accounts to First Federal automatically?
  var customerMoveAccounts: Bool = false
  
  // Create a custom class to track answers as someone moves through the app.
  
  override init() // No initialization needed, just a holder in case it's needed in teh future
  {
      super.init()
  }
  
  
  /// This function resets ALL of the data stored in the currently instanced AnswerTracker class.
  ///
  /// - Parameter confirm: You must send with "Yes" or the function will not reset the data.
  /// - Returns: Returns Bool: true if successful, and Bool: false on failure.
  func resetData(confirm: String) -&gt; Bool {
  
      if confirm == "Yes" {
          businessName = ""
          entityType = 0
          customerPayCredit = false
          customerPayCredit = false
          customerPayChecks = false
          customerPayCash = false
          customerPayDirectDebit = false
          customerDepositChecksOffice = false
          customerDepositChecksBranch = false
          customerDepositChecksATM = false
          customerDepositChecksNight = false
          customerDepositCashBranch = false
          customerDepositCashATM = false
          customerDepositCashNight = false
          customerPayVendorsOnline = false
          customerPayVendorsCheck = false
          customerPayVendorsCredit = false
          customerPayVendorsDebit = false
          customerPayVendorsWire = false
          customerPayVendorsTransfer = false
          customerPreventUnauthedChecks = false
          customerWireInitiateOnline = false
          customerWireRequestOnline = false
          customerWireRequestBranch = false
          customerMoreThanOneWire = false
          customerEmployeePayCheck = false
          customerEmployeePayDirect = false
          customerEmployeePayCompany = false
          customerManageAccountsOnlineSingle = false
          customerManageAccountsOnlineMultiple = false
          customerManageAccountsBranch = false
          customerAccountStatementsOnline = false
          customerAccountStatementsPaper = false
          customerExcessFundsSweep = false
          customerExcessFundsSavings = false
          customerExcessFundsCD = false
          customerExcessFundsFDIC = false
          customerOverdraftsLineOfCredit = false
          customerLoansAndLinesFunding = false
          customerLoansAndLinesRefi = false
          customerReceiveInterest = false
          customerMoveAccounts = false
          return true
      } else {
          return false
      }
  
  }
  }
  </code></pre>