$ grep -r Tag: «restkit»

-rw-r--r-- 803B Jul 2, 2015 · 33C822E · ~1 min

Proper Date Parsing with RestKit. From NSString to NSDate

objective-c restkit шпаргалки

A problem came up because dates were being parsed incorrectly through RestKit - the time zone was not taken into account, so in the end all dates were displayed 3 hours later than they should have been.

Inside RestKit there are already several NSDateFormatters for parsing a date. If one fails, the second one is used, and so on. But none of them matched the format in which I was getting dates through the API. To parse dates correctly, you need to add your own NSDateFormatter, and put it first in the list so it is applied first:

NSDateFormatter *dateFormatter = [[NSDateFormatter alloc] init];
[dateFormatter setDateFormat:@"yyyy-MM-dd'T'HH:mm:ss Z"];

[RKObjectMapping alloc];
[[RKValueTransformer defaultValueTransformer] insertValueTransformer:dateFormatter atIndex:0];
[↵] open page pravilnyj-parsing-dat-cherez-restkit-iz-nsstring-v-nsdate.md
makoni@arm1:~/blog$ cd .. // ↵ back to all posts