mysql - Trouble loading data for TableView from server -
im using web-service api load information db (mysql). when transitioning uitableviewcontroller, retrieve array contains categories in viedidload method. however, not able display array of categories got table view cells. when init category nsmutubalearray , hardcode on otherhand, tableview display information. trying understand i'm doing wrong in steps of loading array , populating onto tableview. here code:
- (void)viewdidload { [super viewdidload]; //when init _categorylist way below, displays info. //_categorylist = [[nsmutablearray alloc] initwithobjects:@"trending",@"sports",@"portraits", @"art",@"iduser", nil]; _tocategory = [[nsstring alloc]init]; //when try populate server doesnt work. _categorylist = [[nsmutablearray alloc]init]; //just call "getcategories" command web api [[api sharedinstance] commandwithparams:[nsmutabledictionary dictionarywithobjectsandkeys: @"getcategories",@"command", nil] oncompletion:^(nsdictionary *json) { //got stream nsarray *temparray = [json objectforkey:@"result"]; (int i=0;i<temparray.count;i++){ [_categorylist insertobject:[temparray objectatindex:i] atindex:i]; } //i verify able retrieve array correct conent. [self printarray:_categorylist]; nslog(@"got categories"); [self.tableview reloaddata]; }]; }
any appreciated. thanks!
update #1:
the json return array nsdictioanry's. print out contents make sure, calling jsonarray objectforkey[‘categories’] , this:
swiphtmvpclone[2410:11303] array @ index 0 = trending swiphtmvpclone[2410:11303] array @ index 1 = sports swiphtmvpclone[2410:11303] array @ index 2 = portraits swiphtmvpclone[2410:11303] array @ index 3 = art
right now, app crashing – getting error:
[__nscfdictionary isequaltostring:]: unrecognized selector sent instance 0x72a85d0
Comments
Post a Comment