テキストを出力する必要があるコード行の直前にある NSLog が正しい値を返しているため、この問題はちょっと奇妙です。
コードは次のとおりです。
-(void)setCurrentDate:(UILabel *)currentDate
{
NSInteger onDay = 1; //because if it's today, you are on day one, not zero... no such thing as a day zero
//get the nubmer of days left
if( [[NSUserDefaults standardUserDefaults] objectForKey:@"StartDate"] ){ //if there is something at the userdefaults
onDay = [self daysToDate:[NSDate date]];
}//otherwise, onDay will just be one
self.theCurrentNumberOfDaysSinceStart = onDay;
NSLog(@"On day: %d", onDay); //this is returning the correct values....
//print it out on the label
[currentDate setText:[NSString stringWithFormat:@"On day: %d", onDay]];//echoes out the current day number
}
したがって、アプリが最初に起動するときは、すべて問題ありません。ラベルの更新とすべて。基本的に新しい日付を取得するボタンを押すと、問題が発生します。その過程で、これを実行します。
//need to reload the "on day" label now
[self setCurrentDate:self.currentDate];
//and the "days left" label
[self setDaysLeft:self.daysLeft];
繰り返しますが、NSLog は正しいものを返しているので、これはすべて正しいはずだと考えています。問題は、私が示した最初のコード ブロックの最後の行にあると考えています... setText の行です。
ご助力いただきありがとうございます!
乾杯、マット