@@ -1282,13 +1282,34 @@ - (void)_mergeAfterSaveWithResult:(NSDictionary *)result decoder:(PFDecoder *)de
1282
1282
}
1283
1283
}
1284
1284
1285
+ static NSString * ISO8601Format = @" yyyy-MM-dd'T'HH:mm:ss.SSS'Z'" ;
1286
+ // http://stackoverflow.com/questions/17558859/convert-iso-8601-to-nsdate
1287
+ static NSDate * NSDateFromISO8601String (NSString * dateString) {
1288
+
1289
+ NSDateFormatter *formatter = [[NSDateFormatter alloc ] init ];
1290
+ [formatter setDateFormat: ISO8601Format];
1291
+ // Always use this locale when parsing fixed format date strings
1292
+ NSLocale *posix = [[NSLocale alloc ] initWithLocaleIdentifier: @" en_US_POSIX" ];
1293
+ [formatter setLocale: posix];
1294
+ [formatter setTimeZone: [NSTimeZone timeZoneForSecondsFromGMT: 0 ]];
1295
+ NSDate *date = [formatter dateFromString: dateString];
1296
+
1297
+ return date;
1298
+ }
1299
+
1285
1300
- (void )_mergeFromServerWithResult : (NSDictionary *)result decoder : (PFDecoder *)decoder completeData : (BOOL )completeData {
1286
1301
@synchronized (lock) {
1287
1302
self._state = [self ._state copyByMutatingWithBlock: ^(PFMutableObjectState *state) {
1288
1303
// If the server's data is complete, consider this object to be fetched.
1289
1304
state.complete |= completeData;
1290
1305
1291
1306
[result enumerateKeysAndObjectsUsingBlock: ^(id key, id obj, BOOL *stop) {
1307
+ if ([obj isKindOfClass: [NSDictionary class ]]) {
1308
+ if (([[obj valueForKey: @" __type" ] isEqualToString: @" Date" ]) &&
1309
+ ([obj valueForKey: @" iso" ])) {
1310
+ obj = NSDateFromISO8601String([obj valueForKey: @" iso" ]);
1311
+ }
1312
+ }
1292
1313
if ([key isEqualToString: PFObjectObjectIdRESTKey]) {
1293
1314
state.objectId = obj;
1294
1315
} else if ([key isEqualToString: PFObjectCreatedAtRESTKey]) {
0 commit comments