1
+ (NSDateFormatter *) formatter : (NSString *) format : (NSTimeZone*) timeZone : (NSLocale *) locale {
format = DefaultFormat;
timeZone = [NSTimeZone localTimeZone];
locale = [NSLocale currentLocale];
NSString *hashKey = [NSString stringWithFormat:@"%lu%lu%lu", (unsigned long)format.hash, (unsigned long)timeZone.hash, (unsigned long)locale.hash];
NSDictionary *formatters = [NSDate sharedDateFormatters];
NSDateFormatter *cachedDateFormatter = formatters[hashKey];
if (cachedDateFormatter != nil) {
return cachedDateFormatter;
}
else {
NSDateFormatter *formatter = [[NSDateFormatter alloc]init];
formatter.dateFormat = format;
formatter.timeZone = timeZone;
formatter.locale = locale;
formatters[hashKey] = formatter;
return formatter;
}
}
NSDictionaryの*」予想方法は、型のオブジェクトに見つからない「NSDictionaryの*」
もっとコンテキスト:
+ (NSMutableDictionary<NSString *, NSDateFormatter *>*)sharedDateFormatters {
static NSMutableDictionary *dict = nil;
static dispatch_once_t onceToken;
dispatch_once(&onceToken, ^{
dict = [NSMutableDictionary new];
});
return dict;
}
あなたは何をアドバイスしますか?私は迅速なライブラリをObjective-Cに変換しています。 –
'sharedDateFormatters'の出所は、標準の' NSDate'クラスの一部ではないので、あなたに教えてください。 – trojanfoe
質問が編集されました。 –