iphone - Why do iOS keychain values not change without leaving the ViewController? -
i have an abstraction on ios keychain api seems work well. basically, has:
public string getgenericpasswordfield(string account) { var record = seckeychain.queryasrecord(query, out code); if (code == secstatuscode.itemnotfound) homecoming null; homecoming nsstring.fromdata(record.valuedata, nsstringencoding.utf8); } public void setgenericpasswordfield(string account, string value) { if (value == null) { seckeychain.remove(record); return; } var record = new secrecord (seckind.genericpassword) { service = service, label = label, business relationship = account, valuedata = nsdata.fromstring (value), }; secstatuscode code = seckeychain.add (record); if (code == secstatuscode.duplicateitem) { // (remove , re-add item) } }
i have used abstraction on app's settings screen save values while leaving, , load values elsewhere in app.
but i've run issue saving value not appear take effect if don't leave current viewcontroller. i'm doing analogous to:
if (keychain.getgenericpasswordfield("remotelogin") == null) { var remotepassword = getfromdialog(); keychain.setgenericpasswordfield("remotelogin", hash(remotepassword)); // safe assume remotelogin password got saved, right? } // later on... if (keychain.getgenericpasswordfield("remotelogin") == null) { // block beingness executed }
i've stepped through code in debugger confirm things i'm describing them, , abstraction method getting secstatuscode.itemnotfound
back, meaning null appropriate value return.
i worked around 1 time moving first half of code previous viewcontroller, , reason seemed wake up, or clear out whatever caching taking place. i've encountered situation that's not practical.
why happening? abstraction leaking?
iphone ios monotouch
No comments:
Post a Comment