Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/ios/113.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Ios 在Restkit中将奇怪的日期字符串映射为NSDate_Ios_Iphone_Objective C_Restkit_Nsdateformatter - Fatal编程技术网

Ios 在Restkit中将奇怪的日期字符串映射为NSDate

Ios 在Restkit中将奇怪的日期字符串映射为NSDate,ios,iphone,objective-c,restkit,nsdateformatter,Ios,Iphone,Objective C,Restkit,Nsdateformatter,我有一个包含开始和结束日期的JSON。但是它们在JSON EndDate: "/Date(1375693200000+0200)/" StartDate: "/Date(1375686000000+0200)/" 我知道您可以将NSDateFormatters添加到RKEntityMapping中,但我不知道如何才能做到这一点?我通常是这样做的 NSDateFormatter *dateFormatter = [NSDateFormatter new]; [dateForma

我有一个包含开始和结束日期的
JSON
。但是它们在
JSON

EndDate: "/Date(1375693200000+0200)/"
StartDate: "/Date(1375686000000+0200)/"
我知道您可以将
NSDateFormatters
添加到
RKEntityMapping
中,但我不知道如何才能做到这一点?我通常是这样做的

 NSDateFormatter *dateFormatter = [NSDateFormatter new];
        [dateFormatter  setDateFormat:@"yyyy-MM-dd HH:mm:ss"];
        dateFormatter.timeZone = [NSTimeZone timeZoneWithAbbreviation:@"GMT"];
        //dateFormatter.locale = [[NSLocale alloc] initWithLocaleIdentifier:@"en_US_POSIX"];

        [RKEntityMapping addDefaultDateFormatter:dateFormatter];

有人能帮忙吗?

但是json中的字符串不是日期。看起来更像是一个时间间隔。尝试提取值1375693200000并创建具有时间间隔的日期

NSTimeInterval timeInterval = 1375693200000;
NSDate *myDate = [NSDate dateWithTimeIntervalSince1970:timeInterval];

您收到的日期是ASP.NET JSON日期。RestKit具有专门针对以下内容的日期:。学习如何使用它