Thanks a lot Blake for pointing in the right direction,
I did the changes as mentioned in the RKDotNetDateFormatter.m and added the
stringForObjectValue: method
but still found no luck,
then i realized that in the Method
- (void)objectMappingOperation:(RKObjectMappingOperation *)operation didSetValue:(id)value forKeyPath:(NSString *)keyPath usingMapping:(RKObjectAttributeMapping *)mapping {
id transformedValue = nil;
Class orderedSetClass = NSClassFromString(@"NSOrderedSet");
if ([value isKindOfClass:[NSDate class]]) {
// Date's are not natively serializable, must be encoded as a string
@synchronized(self.mapping.preferredDateFormatter) {
//-- Changed this line
transformedValue = [[RKDotNetDateFormatter dotNetDateFormatterWithTimeZone:[NSTimeZone systemTimeZone]] stringForObjectValue:value];
}
self.mapping.preferredDateFormatter was always NSDateFormatter , even if i set
[objectMapping setPreferredDateFormatter:[RKDotNetDateFormatter dotNetDateFormatterWithTimeZone:[NSTimeZone systemTimeZone]]]; while initializing the objectmapping
as result the
stringForObjectValue: methood was not called.
So i explicitly changed it to the above given line and it worked.
I know this is not the best way to do it, but i cant understand why
self.mapping.preferredDateFormatter was always NSDateFormatterhere's what i get when i NSLog the
preferredDateFormatter and dateFormatters Array
[objectMapping preferredDateFormatter] = <NSDateFormatter: 0x82b7c60>
[objectMapping dateFormatters] = (
"<NSDateFormatter: 0x82b8340>",
"<NSDateFormatter: 0x82b8270>",
"<RKISO8601DateFormatter: 0x82b8710>"
)
ps: my objectMappings are for an NSManagedObject Class.
Thanks again.