次のコードは、サーバーからJSON応答を受け取ります。これは、要素の配列で構成され、それぞれに「created_at」キーと「updated_at」キーがあります。これらすべての要素について、これら2つのキーに設定されている文字列の1文字(コロン)を削除したいと思います。
- (void)objectLoader:(RKObjectLoader*)loader willMapData:(inout id *)mappableData {
// Convert the ISO 8601 date's colon in the time-zone offset to be easily parsable
// by Objective-C's NSDateFormatter (which works according to RFC 822).
// Simply remove the colon (:) that divides the hours from the minutes:
// 2011-07-13T04:58:56-07:00 --> 2011-07-13T04:58:56-0700 (delete the 22nd char)
NSArray *dateKeys = [NSArray arrayWithObjects:@"created_at", @"updated_at", nil];
for(NSMutableDictionary *dict in [NSArray arrayWithArray:(NSArray*)*mappableData])
for(NSString *dateKey in dateKeys) {
NSString *ISO8601Value = (NSString*)[dict valueForKey:dateKey];
NSMutableString *RFC822Value = [[NSMutableString alloc] initWithString:ISO8601Value];
[RFC822Value deleteCharactersInRange:NSMakeRange(22, 1)];
[dict setValue:RFC822Value forKey:dateKey];
[RFC822Value release];
}
}
ただし、この行はメッセージとともにを発生さ[dict setValue:RFC822Value forKey:dateKey];
せます。NSUnknownKeyException
this class is not key value coding-compliant for the key created_at
私はここで何が間違っているのですか?私の主な問題は、おそらく私がこのinout宣言に本当に満足していないということです...