iphone - Why am I seeing the error "Format is not a string literal and no format arguments"? -
i creating music application in iphone integrating twitter in iphone user can listen particular song click on twitter tab ,log in twitter , post comment in twitter.and need username , password should saved when click on save username , password button remain logged in when in application.
i have done code of saving username , password error indicating ""format not string literal , no format arguments""
here code:
-(ibaction)saveall:(id)sender{ usernamestring =[[nsstring alloc]initwithformat:text1.text]; "format not string literal , no format arguments" [text1 settext:usernamestring]; nsuserdefaults *usernamedefault =[nsuserdefaults standarduserdefaults]; [usernamedefault setobject:usernamestring forkey:@"stringkey"]; passwordstring =[[nsstring alloc]initwithformat:text2.text]; "format not string literal , no format arguments" [text2 settext:passwordstring]; nsuserdefaults *passworddefault =[nsuserdefaults standarduserdefaults]; [passworddefault setobject:passwordstring forkey:@"stringkey2"]; }
please me in solving problem when click on username , password button username , password should saved.
use initwithformat if want create string composed several components, string , integer example this
nsstring *mystring = [nsstring stringwithformat:@"%@ costs %i"itemname, itemprice];
itemname nsstring object, itemprice integer.
in case, try doing following way:
usernamestring =[[nsstring alloc]initwithstring:text1.text];
or easier
usernamestring = text1.text;
note: not recommend store passwords or other sensitive information userdefaults better (more safe/secure way) store passwords use devices keychain, stored information heavily encrypted , access happens in safe way.
also it's easy use:
simple iphone tutorial: password management using keychain using sfhfkeychainutils
hope helps.
Comments
Post a Comment