ios - How do I ensure that the text entered into a UIAlertview transforms the text of a UIButton and STAYS that way after exiting and reentering the app -


tl;dr : open ios app enter promo code close app open app actual results: promo code box out of wack (see images) expected results: promo code should still displayed

so i've got uibutton text keeps changing after user clicks on , exits , reruns app. here's area looks before change:

enter image description here

then, after user clicks on button, they're prompted uialertview enter image description here

finally, after user has entered promo code, return the viewcontroller, , uibutton, after adopting name of promo code, changes size, font, , text. that's intended goal. problem when close app , rerun in simulator, different message appears, rather original promo code entered. enter image description hereenter image description here

i can add more code/explanation upon request. thank in advance help.

edit: here's button looks in storyboard:

enter image description here

nsuserdefaults code:

- (bool)hasstoredpromotioncode {     nsdata *data = [[nsuserdefaults standarduserdefaults] objectforkey:@"userpromotion"];     self.promotion = (pngpromotionmodel *)[nskeyedunarchiver unarchiveobjectwithdata:data];      if (self.promotion) {         return yes;     }      return no; } 

if not able retrieve value nsuserdefaults means it's not getting stored properly.

i'm not sure how using object make sure storing correctly in user defaults.

- (void)storeindefaults:(myobject*)object {    nsuserdefaults *defaults = [nsuserdefaults standarduserdefaults];    [defaults setobject:[nskeyedarchiver archiveddatawithrootobject:object] forkey:@"userpromotion"];    [defaults synchronize]; } 

when use nskeyedarchiver custom objects have make sure object adhere's nscoding protocol implementing initwithcoder: , encodewithcoder. https://developer.apple.com/library/prerelease/ios/documentation/cocoa/reference/foundation/protocols/nscoding_protocol/index.html


Comments

Popular posts from this blog

javascript - Bootstrap Popover: iOS Safari strange behaviour -

Magento/PHP - Get phones on all members in a customer group -

session - Logging Out Using PHP -