-1

現在の日付に基づいて情報を提供する iPhone 用のアプリケーションがあります。たとえば、日付が 10/28/13 の場合、Today's weather is.... などと表示されます。「If-Then」ステートメントを使用して現在の日付を見つけるにはどうすればよいですか? または、日付を自動的に見つけてアプリケーションの表示を調整する別のより良い方法はありますか?

Google カレンダー API を使用してこれを実装しようとしましたが、それも機能しませんでした。

どうもありがとう!これは私の iOS での 2 番目のアプリなので、たくさんの助けが必要です! ありがとう!

編集誰かが後でこれを必要とする場合に備えて、これは私が最終的に私のために働かなければならないものです

     NSDateFormatter *df= [[NSDateFormatter alloc] init];

[df setDateFormat:@"yyyy-MM-dd"];

NSDate *date1 = [df dateFromString:@"2013-10-27"];
NSDate *date2 = [df dateFromString:@"2013-10-28"];
NSDate *currentDate = [NSDate date];

[[NSCalendar currentCalendar] rangeOfUnit:NSDayCalendarUnit startDate:&date1 interval:NULL forDate:date1];
[[NSCalendar currentCalendar] rangeOfUnit:NSDayCalendarUnit startDate:&currentDate interval:NULL forDate:currentDate];
if ([currentDate isEqualToDate:date1]) {
    crowdLabel.text = [NSString stringWithFormat:@"%@", itsOk];
} else {
    crowdLabel.text = [NSString stringWithFormat:@"Not Working"];
}
4

1 に答える 1