trying to parse JSON from http://sec.kimonolabs.com/companies with the JSONModel framework but the problem is that values logged come out as null.
I am trying to output the name and cik of some companies with the SEC API on a table view but currently there is no output because the values are null.
The .m files for the below code are just default with no custom code.
Any help appreciated!
LoanModel.h
#import "JSONModel.h"
//#import "LocationModel.h"
@protocol LoanModel @end
@interface LoanModel : JSONModel
@property (strong, nonatomic) NSString* cik;
@property (strong, nonatomic) NSString* display_name;
@property (strong, nonatomic) NSString* name;
//@property (strong, nonatomic) LocationModel* location;
@end
KivaFeed.h
#import "JSONModel.h"
#import "LoanModel.h"
@interface KivaFeed : JSONModel
@property (strong, nonatomic) NSArray<LoanModel>* company;
@end
MasterViewController.h
#import "MasterViewController.h"
#import "JSONModelLib.h"
#import "KivaFeed.h"
@interface MasterViewController () {
KivaFeed* _feed;
}
@end
@implementation MasterViewController
-(void)viewDidAppear:(BOOL)animated
{
//show loader view
//[HUD showUIBlockingIndicatorWithText:@"Fetching JSON"];
//fetch the feed
_feed = [[KivaFeed alloc] initFromURLWithString:@"http://sec.kimonolabs.com/companies" completion:^(JSONModel *model, JSONModelError *err) {
//hide the loader view
//[HUD hideUIBlockingIndicator];
//json fetched
NSLog(@"loans: %@", _feed.company);
NSLog(@"loans: %@", _feed.company);
//reload the table view
[self.tableView reloadData];
}];
}
#pragma mark - table methods
-(NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
{
return 1;
}
-(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
return _feed.company.count;
}
-(UITableViewCell*)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
LoanModel* loan = _feed.company[indexPath.row];
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"Cell" forIndexPath:indexPath];
cell.textLabel.text = [NSString stringWithFormat:@"%@ and %@", loan.name, loan.cik];
return cell;
}
@end