iphone - how to validate string in NSUserdefaults -
i getting id web services.
eg:101.
that id save in nsuserdefaults , give value string.
now need validate string if string equal 0 need fire 1 action , if value not equal 0 need fire action.
for code this.
nslog(@"id is%@",[defaults objectforkey:@"id"]); nsstring *intstring = [nsstring stringwithformat:@"%d", [defaults objectforkey:@"id"]]; nslog(@"string %@",intstring); if ([intstring isequaltostring:@"0"]) { nslog(@"yes 0"); } else { nslog(@"no not eqal zero"); }
for first time in console id 0,string 0
and if check second time id 0, string 100243248.
i did n't 100243248 value.
i need check id in nsuserdefaults. if value 0 need fire 1 action , if value not equal 0 need fire action.
how can done can 1 please me.
thank u in advance.
try doing instead: nsstring *intstring = [nsstring stringwithformat:@"%@", [defaults objectforkey:@"id"]];
you're not being consistent in store in nsuserdefaults
, looks like.
hope helps!
Comments
Post a Comment