I get data from a request that has the next structure:
"result" from the NSDictionary stores info, this is the method I use.
-(void)loadLinks{
NSDictionary *dictToSend = @{@"controller": @"link",
@"action": @"loadall"
};
[ApiCaller sendDictionary: dictToSend
toURL: nil
withKey: nil
completionHandler: ^(NSDictionary *result, NSError *error) {
if (!error) {
[CommonFunctions desActivateIndicator];
DCArrayMapping *mapper = [DCArrayMapping mapperForClassElements:[JSONLink class] forAttribute:@"data" onClass:[JSONLinks class]];
DCParserConfiguration *config = [DCParserConfiguration configuration];
[config addArrayMapper:mapper];
DCKeyValueObjectMapping *parser = [DCKeyValueObjectMapping mapperForClass:[JSONLinks class] andConfiguration:config];
linksData = [parser parseDictionary: result];
[tableview reloadData];
}
}];
}
I'm using this to fill a tableview with some links. The error is the next.
*** Terminating app due to uncaught exception 'NSUnknownKeyException', reason: '[<JSONLink 0x7fc7f0c759b0> setValue:forUndefinedKey:]: this class is not key value coding-compliant for the key description.'
My JSONLinks.h file:
#import <Foundation/Foundation.h>
@interface JSONLinks : NSObject
@property (nonatomic, strong) NSNumber *success;
@property (nonatomic, strong) NSArray *data;
@end
My JSONLink.h file:
#import <Foundation/Foundation.h>
@interface JSONLink : NSObject
@property (nonatomic, strong) NSNumber *idd;
@property (nonatomic, copy) NSString *name;
@property (nonatomic, copy) NSString *url;
@property (nonatomic, copy) NSString *descriptionData;
@property (nonatomic, copy) NSString *photo;
-(NSString *) urlDirection;
@end
Where is the error? :S
Thank you.