Die App, die ich arbeite geht den Benutzer durch ein Interview und spuckt ein PDF mit Produktempfehlungen basierend auf ihren Antworten aus. Ich habe momentan ein Problem mit einigen Telefonen, die die Variablen nicht zu unvorhersehbaren Zeiten richtig einstellen.Variablen nicht intervallmäßig gesetzt
Die Daten werden in einer Klasseninstanz namens "newTracker" gespeichert, und (für den Umfang dieser Frage) werden die Antworten als bool gespeichert. Der Beispielcode stammt von einem Bildschirm mit nur einer Frage, einem UISwitch und einer Schaltfläche "Next".
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
}
Die meiste Zeit dieser Code funktioniert gut, aber einmal in eine Weile, es wird die Variable newTracker.customerMoreThanOneWire nicht speichern. Wenn es passiert, passiert es überall in der App und der Code ist gleich strukturiert. Ich hatte ein Problem in der Vergangenheit, wo es war Speichern der Variablen richtig, nur nicht die ursprüngliche Schalterzustand richtig einstellen, aber in diesem Fall, es spart überhaupt nichts.
Wäre es hilfreich, wenn die Variablen auf Value Change statt auf Touch Up Inside gesetzt wären? Ich bin ratlos, warum das nur zufällig passiert. Ich hatte eines der Telefone in meinen Händen, als das ging, und es gab keine anderen Anwendungen im Hintergrund, das Betriebssystem wurde aktualisiert, und es schien keine Spielereien wie Jailbreak oder irgendetwas anderes passiert.
Ich konnte das nicht mit einem Emulator oder einem Telefon in meinem Entwicklungscomputer replizieren.
Irgendwelche Einsichten?
EDIT: Hier ist der Antwort-Tracker-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) -> 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
}
}
}
Können Sie den newTracker-Klassencode anzeigen? –
Lassen Sie mich meine Frage bearbeiten, um es aufzunehmen. –
Wo wird die newTracker-Variable initialisiert? Die AnswerTracker-Klasse scheint ihre Daten nirgends zu speichern. Wenn Ihre verschiedenen Ansichten nicht dieselbe Instanz (von newTracker) verwenden oder wenn sie irgendwo neu initialisiert wird, könnte dies erklären, warum Werte scheinbar nicht gespeichert werden. –