ios - Strings which should be equal compare as not equal -


this question has answer here:

i want build app shows string every day, don't know how detect new day has come.

i tried setting string initialstring records day of last time opened app, , string nowstring records current time. if initialstring != nowstring, show new string in uilabel in app , update initialstring same nowstring. if they're same, nothing happens.

heres code; compiler says both strings not same when are.

implementation file:

#import "quoteviewcontroller.h" #import "quotes.h"  @interface quoteviewcontroller ()  @end  @implementation quoteviewcontroller  @synthesize view1; @synthesize view2;  //will used in future. //@synthesize view3;    - (void)viewdidload {     // additional setup after loading view, typically nib.     [super viewdidload];      [self addchildviewcontroller:[self.storyboard instantiateviewcontrollerwithidentifier:@"view1"]];     [self addchildviewcontroller:[self.storyboard instantiateviewcontrollerwithidentifier:@"view2"]];      self.quotes = [[quotes alloc] init];      self.now = [[nsdate alloc] init];     self.initialstring = @"1";      [self timer];  }  #pragma mark - timer  - (void) timer {      //this repasts method checkdate every 1 second      [nstimer scheduledtimerwithtimeinterval:1.0f                                      target:self                                    selector:@selector(checkdate)                                    userinfo:nil                                     repeats:yes];  }  #pragma mark - checkdate  - (void) checkdate {      //date      nsdateformatter *dateformatter = [[nsdateformatter alloc]init];     [dateformatter setdateformat:@"dd"];      nsstring *nowstring = [dateformatter stringfromdate:self.now];      nslog(@"self.initialstring is: %@", self.initialstring);     nslog(@"now is: %@", nowstring);       //both strings same compiler still says they're not same , keep calling method [showquote]      if (self.initialstring != nowstring) {         self.initialstring = nowstring;         [self showquote];          nslog(@"after method string %@", self.initialstring);     }      else { nslog(@"it's same");}  }  #pragma mark - showquote  - (void) showquote {     self.quotelabel.text = [self.quotes randomquote]; }  @end 

what problem comparison of these strings?

uiapplicationdelegate's applicationsignificanttimechange: inform when new day begins.


Comments

Popular posts from this blog

c++ - OpenCV Error: Assertion failed <scn == 3 ::scn == 4> in unknown function, -

php - render data via PDO::FETCH_FUNC vs loop -

The canvas has been tainted by cross-origin data in chrome only -