Parsing json in iOS NULL -
trying parse json http://sec.kimonolabs.com/companies jsonmodel framework problem values logged come out null.
i trying output name , cik of companies sec api on table view there no output because values null.
the .m files below code default no custom code.
any 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 feed _feed = [[kivafeed alloc] initfromurlwithstring:@"http://sec.kimonolabs.com/companies" completion:^(jsonmodel *model, jsonmodelerror *err) { //hide loader view //[hud hideuiblockingindicator]; //json fetched nslog(@"loans: %@", _feed.company); nslog(@"loans: %@", _feed.company); //reload 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:@"%@ , %@", loan.name, loan.cik]; return cell; } @end
Comments
Post a Comment