how to print a string to UITextField in xcode ios -


i m having mobile number, saved in nsstring variable in program, want display in uitextfield when user gets window of user details in ios app. want disable editing of phone number. how can that? m using xcode 7.4.2

initially check string contains value or not , like

yourmobilenumbertextfield.userinteractionenabled = true; if (yourstring.length > 0) {  yourmobilenumbertextfield.text = yourstring;  yourmobilenumbertextfield.userinteractionenabled = false;  } 

swift

yourmobilenumbertextfield.userinteractionenabled = true if yourstring.length > 0 { yourmobilenumbertextfield.text = yourstring yourmobilenumbertextfield.userinteractionenabled = false } 

update

for hold previous value in app go nsuserdefault,

step-1

when otp verification success save current mobile number in userdefaults

 [[nsuserdefaults standarduserdefaults] setobject:yourmobilenumbertextfield.text forkey:@"mobile"]; 

step-2

if second time user comes on page need call

nsstring *savedvalue = [[nsuserdefaults standarduserdefaults] stringforkey:@"mobile"];  yourmobilenumbertextfield.userinteractionenabled = true; if (savedvalue.length > 0) {  yourmobilenumbertextfield.text = savedvalue;  yourmobilenumbertextfield.userinteractionenabled = false;  } 

swift

save

        nsuserdefaults.standarduserdefaults().setobject(yourmobilenumbertextfield.text, forkey: "mobile") 

retrieve

  let savedvalue =  nsuserdefaults.standarduserdefaults().stringforkey("mobile")! yourmobilenumbertextfield.userinteractionenabled = true if savedvalue.length > 0 { yourmobilenumbertextfield.text = savedvalue yourmobilenumbertextfield.userinteractionenabled = false } 

Comments

Popular posts from this blog

java - Jasper subreport showing only one entry from the JSON data source when embedded in the Title band -

serialization - Convert Any type in scala to Array[Byte] and back -

SonarQube Plugin for Jenkins does not find SonarQube Scanner executable -