そのため、関数の外で書式設定された日付にアクセスして表示したいと思います。私が使用している日付形式については、NSDateFormatter
うまく機能します..
私の関数 ( didFinishUpdatesSuccessfully
) は何らかのアクションを実行し、成功した場合UIAlertView
はフォーマットされた日付を含む を表示します。すべて正常に動作します..
- (void) didFinishUpdatesSuccessfully {
//--- Create formatted date
NSDate *currDate = [NSDate date];
NSDateFormatter *dateFormatter = [[NSDateFormatter alloc]init];
[dateFormatter setDateFormat:@"dd/MM/YYYY - hh:mm:ss a"];
NSString *dateString = [dateFormatter stringFromDate:currDate]; // dateString contains the current date as a string
[dateFormatter release];
//--- UIAlertView
NSString *title = @"The update has been performed!";
UIAlertView *alert = [[UIAlertView alloc] initWithTitle: title
message: dateString
delegate: nil
cancelButtonTitle: [FileUtils appResourceForKey:@"UPDATE_GENERAL_BUTTON_TITLE_OK"]
otherButtonTitles: nil];
[alert show];
[alert release];
//--- create new string
// NSMutableString* lastUpdated = [NSMutableString stringWithFormat:@"%@",dateString];
}
dateString
の値をグローバルに書き込むNSString
かNSMutableString
、コード内の別の場所、たとえば別の関数などにアクセスしたいと考えています。
私はこのようなものを作成することを考えましたNSMutableString
:
そしてどこかNSMutableString* lastUpdated = [NSMutableString stringWithFormat:@"%@",dateString];
にアクセスするために、しかしこの関数の外側は空です...助けてもらえますか?乾杯lastUpdated
lastUpdated